ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Questions about hardware, drivers and peripherals
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
mcurran

ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by mcurran »

Hello:

I have an ASUS G1Sn-B1 laptop (see picture in signature) and I use the following to turn on the various LED lights on the front and side of my notebook.

(I'VE UPDATED THE DIRECTORY TREE FOR THE COMMANDS BELOW, TO COMPENSATE FOR THE CHANGES WITH THE MOST RECENT RELEASE OF asus-laptop)


# Gain Appropriate Permissions
sudo -s

# Load Module
sudo modprobe asus-laptop

# Turn On Side-Lights (Gaming)
sudo echo 1 > /sys/class/leds/asus\:gaming/brightness (UPDATE: sudo echo 1 > /sys/class/leds/asus::gaming/brightness)

# Turn Off Side-Lights (Gaming)
sudo echo 0 > /sys/class/leds/asus\:gaming/brightness (UPDATE: sudo echo 0 > /sys/class/leds/asus::gaming/brightness)

# Turn On Front-Light (Touchpad)
sudo echo 1 > /sys/class/leds/asus\:touchpad/brightness (UPDATE: sudo echo 1 > /sys/class/leds/asus::touchpad/brightness)

# Turn Off Front-Light (Touchpad)
sudo echo 0 > /sys/class/leds/asus\:touchpad/brightness (UPDATE: sudo echo 0 > /sys/class/leds/asus::touchpad/brightness)

# Turn On eMail-Light (Mail)
sudo echo 1 > /sys/class/leds/asus\:mail/brightness (UPDATE: sudo echo 1 > /sys/class/leds/asus::mail/brightness)

# Turn Off eMail-Light (Mail)
sudo echo 0 > /sys/class/leds/asus\:mail/brightness (UPDATE: sudo echo 0 > /sys/class/leds/asus::mail/brightness)


If I do a restart, the modules will stay loaded (default is off), but they are reset with a reboot/shutdown. Is there any way I can set this up so that these files get run on startup? I was going to try Sessions, but it seems this would be a bit more complicated. Is there a program I can download to run modules on startup? Please let me know. Or even better; just edit a file so default is all on? These just appear to be image files in the mentioned directories, so I can't really edit anything at this point.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 4 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Husse

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by Husse »

You seem to know a bit so I'll give short answer
You could make a script, test that it works, put in in init.d and create a symlink to the proper rc.d folder (should be rc.d5 :))
mcurran

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by mcurran »

These rc-scripts seem to try to hard to reference/handlle a simple command/instruction (e.g. to much jumping around), is it because boot processes like init need simple instructions and cannot use gtk (for example) like I would in a terminal (or whatever language it is - I'm pretty sure it's gtk, right :) ). Well I'm just wondering, because If I'm really gonna go all out for this and study rc scripts, I'm gonna want to make them flash like they do in Windows, for the hell of it. Would I be better off creating a higher level program and put it on my taskbar and use easier dependencies. Haha, I'm procrastinating, somebody must've done this already... No?

Hey, maybe if I do put in the effort, I might learn something and then build myself a sophisticated boot level framebuffer that'll get my grub at 1680x1050.

You should just ask someone to setup a Mint chat and host it if your posting this much anyways, Husse.

Hey, you know you want to write the two files for me. PLEASE? I didn't get past C++, and this will take me a long while to understand: http://wiki.debianhelp.org/pmwiki.php/D ... nitScripts
Husse

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by Husse »

Ah
You do a simple bash script or rather sh script
#!/bin/sh
or
#!/bin/bash
I'm not versatile in this but I make may way around
I think I have to come back to this - time is lacking :)
mcurran

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by mcurran »

I didn't create a script. I just downloaded and installed the latest asus-laptop module: acpi4asus-0.41

I just untarred the package acpi4asus-0.41-tar.bz2 and did make and then make install - just like I would for any package and it worked. Not sure if there will be problems later on, since I didn't compile the kernel or anything like others suggested. But it works perfect - NICE!

Nope, wait, I was wrong - Must've just been because I booted Windows first and for some reason the lights were kept on. Damn!
Husse

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by Husse »

I booted Windows first
This is because "hardware secrets" are revealed to M$ but not to others
This way Windows can use some firmware "tricks" that Linux can't
Boot into Windows > use the thing (sound wifi whatever) > boot back into Linux and you'll find that it remains on in a large number of cases
mcurran

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by mcurran »

Any assistance would be much appreciated. I'm sure editing the rc files for adding bootup scripts and then creating the symlink is easy - I just can't understand the HowTo's all over the net. Am I missing something, or are people purposely not writing these tutorials for noobs?
Husse

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by Husse »

Somewhat short description
Make a script - remember the first line is always #!bash or #!sh
Put it in /etc/init.d
Make it executable and owned by root
Make a symlink (all links you make are probably symlinks so don't worry about the sym part) to the script which you put in
/etc/rc5.d
and name it S99your_script
There are different ways to achieve this and don't worry about why and why S99 - look that up in google if you are interested
mcurran

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by mcurran »

Thanks Husse. I don't understand what the script would be though, would it just be the commands? I get the part about where you save them. But would the script just be:

(Beginning of text file)
#!/bin/sh

sudo echo 1 > /sys/class/leds/asus\:gaming/brightness

(End of text file)

So root privelages and the asus-module would already be loaded at that runlevel? Well I think the asus-module would be loaded anyways, because I haven't had to manually load that since I installed it and replaced acpi.
Husse

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by Husse »

Maybe I missed something - do you load all the lines in the first post in one instant?
That's what I assumed
mcurran

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by mcurran »

No, I'll run each command separately, so If I wanted to turn on the front led and side leds, I would have to do this in a terminal:

sudo -s

(my password)

sudo echo 1 > /sys/class/leds/asus\:gaming/brightness

sudo echo 1 > /sys/class/leds/asus\:touchpad/brightness
Husse

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by Husse »

But if so why do you want to run the script at boot ?
mcurran

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by mcurran »

Because I want the LED lights on by default. I like them, and they're green, so they match my OS now. :o

So these two commands turn on the lights on the side of my lcd screen, and a light by the touchpad. But initially I needed to load the asus-laptop module, since that's the driver, and sometimes I had to be root to load the module. But now the module automatically loads at startup, but the lights don't turn on, unless I open a terminal and run the commands.

Seriously, wouldn't have it taken you less time to just tell me what to do by now? I just can't figure this one out for some reason.
mcurran

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by mcurran »

If anyone can provide me some instruction on creating a startup script in init.d and rc5.d I would greatly appreciate it. Please help.
Husse

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by Husse »

I started to write an answer but I lost internet (just a few minutes) a couple of times today...
This has gone down deep before you bumped it - august 25 is on page 5 in my posts (this is the date of the previous post)
If you want the two leads in you example above to light up then something like this
First the script - lets call it ledlight

Code: Select all

#! /bin/bash
#to get leds to light up
echo 1 > /sys/class/leds/asus\:gaming/brightness
echo 1 > /sys/class/leds/asus\:touchpad/brightness
Then the symlink

Code: Select all

ln /etc/init.d/ledlight  /etc/rc5.d/S45ledlight
The number S45 indicates at what time in the boot sequence the script is to be run S45 is about the middle - just a guess
mcurran

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by mcurran »

Thanks Husse, you're the man!

I'm almost there. I got the script file saved in init.d and created the symlink. I can both run the symlink and display it, and it works when I run it; however, it is not loading/executing on startup (Tried both restart and reboot). Do I need to put the sudo in front of each command or try runlevel 6? I've tried a few things, but it just doesn't want to work by itself for some reason. I tried changing it to a sh script, but that didn't help much...
mcurran

Re: ASUS G1 Series (LED's) - Load Module/Command On Start-Up?

Post by mcurran »

Hi Husse:

Got it working (FYI: changed the names to asus-leds and S45asus-leds respectively)

had to do:

sudo update-rc.d S45asus-leds defaults (At first it said the file didn't exist, so I had to put a symlink in init.d and then create the startup for some reason)

When I tried this, in order to keep the symlink in the rc5.d runlevel folder, I got the following:

sudo update-rc.d /etc/rc5.d/S45asus-leds defaults
update-rc.d: /etc/init.d//etc/rc5.d/S45asus-leds: file does not exist (even though file did exist w/ appropriate permissions)

WHY? It's not really important to have this sqeaky clean, since it's working, but I'm just curious why the auto update command only works if the symlink is in init.d and not one of the runlevel folders (in this case: rc5.d)

Also the automated startup creation command update-rc.d created a bunch of symlink start and stop shortcuts in init.d two, which is messy.
Locked

Return to “Hardware Support”