Lubuntu 13.04 and Samsung Series 7 Keyboard Backlight

Samsung Series 7 Chronos Lubuntu + backlight by mightyuhu

I’ using Lubuntu 13.04 more and more often lately on my Samsung Series 7 Chronos 700Z5A. While the most things worked pretty right out of the box. It took me a while to figure out why the adjustable keyboard backlight FN-Keys were not working. While there are plenty resources available for the Series 9 but no one in particular for Lubuntu and openboxi/i3 i’ve decided to share the knowledgde with the public and not only with google and the NSA.

The first think i’ve noticed that the standard installation has already loaded the samsung_labtob kernel module. You may check that by running

lsmod | grep samsung
view raw check-mod.sh hosted with ❤ by GitHub

You also can test if the module works by setting a value between 1 and 8 to the backlight driver:

echo 5 > /sys/class/leds/samsung\:\:kbd_backlight/brightness
view raw echo-brightness hosted with ❤ by GitHub

Unfortunately the udev mappings were not defined so i had to manually add the following lines to my /lib/udev/keymaps/samsung-other

0x96 kbdillumup # keyboard backlit up
0x97 kbdillumdown # keyboard backlit down
view raw samsung-other hosted with ❤ by GitHub

and also add the following to the /lib/udev/keymaps/force-release/samsung-other

0x96 # keyboard backlit up
0x97 # keyboard backlit down

You may have to reload udev by

sudo udevadm trigger
view raw reload-udev hosted with ❤ by GitHub

and reboot. After that you can check whether your mappings work by running

sudo /lib/udev/keymap -i input/event3
view raw check-mapping hosted with ❤ by GitHub

the kbdillumup and kbdillumdown events should appear.

Now the next thing we need to do is bind those keyboard events to an action. In order to allow a script to change the driver values i’ve setup a init script in /etc/init.d/brightness.sh

#!/bin/sh
# make it possible to change brightness
chmod 0777 /sys/devices/platform/samsung/leds/samsung::kbd_backlight/brightness
chgrp users /sys/devices/platform/samsung/leds/samsung::kbd_backlight/brightness

and gave it execution rights. Furthermore, i’ve added the following line to my /etc/rc.local that executes that script

sh /etc/init.d/brightness
view raw etc-rc.local hosted with ❤ by GitHub

Then, i wrote a tiny shell script in my home directory /home/bewo/Scripts/backlight.sh that allows me to increment or decrement the current backlight value

#!/bin/bash
light=$(cat /sys/class/leds/samsung\:\:kbd_backlight/brightness);
max_light=$(cat /sys/class/leds/samsung\:\:kbd_backlight/max_brightness);
if [ "$1" == "inc" ]; then
newlight=$((light + 1));
if [ $newlight -gt $max_light ]; then
newlight=8;
fi
else
newlight=$((light - 1));
if [ $newlight -lt 0 ]; then
newlight=0;
fi
fi
echo $newlight > /sys/class/leds/samsung\:\:kbd_backlight/brightness
echo keyboard lightness is now : $newlight;
view raw backlight.sh hosted with ❤ by GitHub

In order tu run it without a prefix-path i’ve created a symbolic link to it

view raw link_script.sh hosted with ❤ by GitHub

Finally all was left to do is to bind my shell script in OpenBox by adding the following keybinds to my .config/openbox/lubuntu-rc.xml:

<keybind key="XF86KbdBrightnessUp">
<action name="Execute">
<command>kbbrightness inc</command>
</action>
</keybind>
<keybind key="XF86KbdBrightnessDown">
<action name="Execute">
<command>kbbrightness dec</command>
</action>
</keybind>

When you’re using i3 you can add the following to your .i3/config analogically

bindsym XF86KbdBrightnessUp exec 'kbbrightness inc'
bindsym XF86KbdBrightnessDown exec 'kbbrightness dec'
view raw .i3-config hosted with ❤ by GitHub

If that does not work check by running xev if you’re bindings trigger the proper X11 events.

Comments