My Laptop is an Asus N56V and previously, using Gnome or KDE, everyone had something to control the backlight. Now, using Fluxbox, there’s nothing – but Fluxbox is awesome ! 🙂
Here’s how I’ve managed to control the backlight using fluxbox
Your’re going to need the following kernel modules:
asus_nb_wmi asus_wmi
They’re found at:
Device Drivers ->
X86 Platform Specific Device Drivers ->
Asus Laptop Extras
Asus WMI Driver ->
Asus Notebook WMI Driver
After loading the modules, you should have the following directories:
cd /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight
and inside, files and directories. What we’re looking for are the files brightness and max_brightness. If you have those, then we’re ok !
Fabien Loison has developed a small program to work with the Asus keyboard backlight. Head over to http://projects.flogisoft.com/ and get the files for Asus Keyboard backlight. The latest version is 0.1
You can check the files here:Â http://projects.flogisoft.com/asus-keyboard-backlight/download/
Before untar and install, make sure you have the dependencies meet. Read the README file.
If you meet the dependencies, go ahead
tar -zxvf asus-kbd-backlight_0.1_src.tar.gz
cd asus-kbd-backlight-0.1
And, to install, as root:
./install.sh --install
Now, after installed, is necessary to change the location of the files (those in /sys/….)
vi /etc/init.d/asus-kbd-backlight
Change the path in the variable BRIGHTNESS_FILE
After is changed, add it to default runtime and start it
(I’m using openRC – If using systemd adjust accordingly)
rc-update asus-kbd-backlight default
/etc/init.d/asus-kbd-backlight start
Now, let’s see if is working:
Get the max brightness value
cat /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/max_brightness
and some value should be returned – mine was 3
Get the current brightness value:
cat /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/brightness
and a value shoud be returned – mine was 1
To change the brightness of the keyboard backlight, we just need to change the returned value of the brightness file with one between 0 and max_brightness. Our problem is that these files can only be written by root – but fluxbox is running with our user. Here enters sudo.
I’m not going to explain how sudo works – ArchWiki has a very nice tutorial on it. Just edit the file with visudo and uncomment the following line:
# Same thing without a password %wheel ALL=(ALL) NOPASSWD: ALL
For these to work, your user must be in the wheel group.
Increase and reduce brightness
Create the following files for reducing and increasing brightness
Increase brightness
[code language=”bash” title=”increase-brightness”]
#!/bin/bash
# Path to brightness files
# Replace the path with yours
bpath=/sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/brightness
# cat max_brightness in above path to discover the max_brightness
maxb=3
# Discover the current brightness
cur_b=`cat $bpath`
# if brigthness is less than max
if [ $cur_b -lt $maxb ]
then
   let cur_b++
fi
# Increase brightness
`sudo sh -c "echo $cur_b > $bpath"`
[/code]
Reduce brightness
[code language=”bash” title=”decrease-brightness”]
#!/bin/bash
# Path to brightness files
# Replace the path with yours
bpath=/sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/brightness
# Discover the current brightness
cur_b=`cat $bpath`
# if brigthness is less than max
if [ $cur_b -gt 0 ]
then
let cur_b–
fi
# Increase brightness
`sudo sh -c "echo $cur_b > $bpath"`
[/code]
Save the files, make them executable and remember the location
Using xev, discover the key codes for Fn + F3 (reduce brightness) and Fn + F4 (increase brightness) Â or just create your own combination.
xev returns 237 for Fn + F3 and 238 for Fn + F4 – Those are the codes to use in keys file for fluxbox keyboard shortcuts
Edit yor fluxbox keys file – most likely in ~/.fluxbox/
Anywhere on the file, Â add the following lines:
[code language=”bash”]
# Keyboard backlight brightness
# increase brightness
238 :Exec <file_path>/increase-brightness
# # decrease brightness
237 :Exec <file_path>/reduce-brightness
[/code]
Note: <file_path> is the location of the above two files
Save and reload fluxbox configuration
Now you can increase and reduce the brightness backlight of the keyboard in fluxbox