Gentoo Fluxbox Asus Keyboard backlight control

keyboard light

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:


They’re found at:

After loading the modules, you should have the following directories:

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

And, to install, as root:

Now, after installed, is necessary to change the location of the files (those in /sys/….)

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)

Now, let’s see if is working:

Get the max brightness value

and some value should be returned – mine was 3

Get the current brightness value:

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:

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

Leave a Reply

Your email address will not be published. Required fields are marked *