Some function keys need a bit adjustment, this is what I did:
Making sound keys work
In LXDE you just have to set the keybindungs. Add the following lines in your ~/.config/openbox/lxde-rc.xml in the keyboard section:
<keybind key="XF86AudioLowerVolume">
<action name="Execute">
<command>amixer -c 0 -- set Master playback 2dB-</command>
</action>
</keybind>
<keybind key="XF86AudioRaiseVolume">
<action name="Execute">
<command>amixer -c 0 -- set Master playback 2dB+</command>
</action>
</keybind>
<keybind key="XF86AudioMute">
<action name="Execute">
<command>amixer -c 0 -- set Master playback toggle</command>
</action>
</keybind>
Making backlight keys work
This is bit more work. Unfortunatley xbacklight does not work, so you have to set the pci-parameters directly. Thanks to archlinux, there is a script to do so. Just put the following in your /usr/local/sbin:
#!/bin/bash
# increase/decrease/set/get the backlight brightness (range 0-255)
#
# PCI device on which to operate
DEVICE=00:02.0
# Amount to raise/lower the backlight when called with "up" or "down"
AMOUNT=10
# Minimum backlight value reachable via "down"
MIN=20
# Default backlight level when toggling on (HEX value!)
DEFAULT=80
#get current brightness in hex and convert to decimal
var1=`setpci -s $DEVICE F4.B`
var1d=$((0x$var1))
case "$1" in
up)
#calculate new brightness
var2=`echo "ibase=10; obase=16; a=($var1d+$AMOUNT);if (a<255) print a else print 255" | bc`
echo "$0: increasing brightness from $((0x$var1)) to $((0x$var2))"
setpci -s $DEVICE F4.B=$var2
;;
down)
#calculate new brightness
var2=`echo "ibase=10; obase=16; a=($var1d-$AMOUNT);if (a>$MIN) print a else print $MIN" | bc`
echo "$0: decreasing brightness from $((0x$var1)) to $((0x$var2))"
setpci -s $DEVICE F4.B=$var2
;;
set)
var2=`echo "ibase=10; obase=16; a=$2;if (a>$MIN) print a else print $MIN" | bc`
echo "$0: setting brightness to $((0x$var2))"
setpci -s $DEVICE F4.B=$var2
;;
get)
echo "$0: current brightness is $var1d"
;;
toggle)
if [ $var1d -eq 0 ] ; then
echo "toggling up"
setpci -s $DEVICE F4.B=$DEFAULT
else
echo "toggling down"
setpci -s $DEVICE F4.B=0
fi
;;
*)
echo "usage: $0 {up|down|set <val>|get|toggle}"
;;
esac
exit 0
The script should be
-rwx------ 1 root root
Then allow your user to execute is as root (as it uses setpci) by visudo and adding the line:
name_of_the_user ALL=(root) NOPASSWD: /usr/local/sbin/backlight_samsung
(I called the script backlight_samsung)
And finally add the keybindungs. In LXDE it is by adding the following lines to your ~/.config/openbox/lxde-rc.xml (keyboard section):
<keybind key="XF86MonBrightnessUp">
<action name="Execute">
<command>sudo /usr/local/sbin/backlight_samsung up</command>
</action>
</keybind>
<keybind key="XF86MonBrightnessDown">
<action name="Execute">
<command>sudo /usr/local/sbin/backlight_samsung down</command>
</action>
</keybind>
<keybind key="XF86Launch1">
<action name="Execute">
<command>sudo /usr/local/sbin/backlight_samsung toggle</command>
</action>
</keybind>
Switching Blutooth and WLAN
This is done by rfkill and to make it nicer I added osd_cat (from xosd-bin).
The process is the same as above, so I skip the details. Your need two more scripts:
#!/bin/bash
blocked=`rfkill list wlan | grep "Soft blocked: yes"`
if [ -z "$blocked" ]; then
rfkill block wlan
echo 'WLAN off' | osd_cat -p middle -A center -d 1 -f -misc-fixed-bold-r-normal--20-200-75-75-c-120-iso8859-1 -
else
rfkill unblock wlan
echo 'WLAN on' | osd_cat -p middle -A center -d 1 -f -misc-fixed-bold-r-normal--20-200-75-75-c-120-iso8859-1 -
fi
which I called wlan_toggle and put it in /usr/local/sbin.
The next is bluetooth_toggle (also in /usr/local/sbin):
#!/bin/bash
blocked=`rfkill list bluetooth | grep "Soft blocked: yes"`
if [ -z "$blocked" ]; then
rfkill block bluetooth
echo 'Bluetooth off' | osd_cat -p middle -A center -d 1 -f -misc-fixed-bold-r-normal--20-200-75-75-c-120-iso8859-1 -
else
rfkill unblock bluetooth
echo 'Bluetooth ein' | osd_cat -p middle -A center -d 1 -f -misc-fixed-bold-r-normal--20-200-75-75-c-120-iso8859-1 -
fi
Don't forget the sudo settings and then the last step is again the keybinding. For bluetooth I choosed Fn+F8, (don't what the key symbol really means). In LXDE it looks like:
<keybind key="XF86Launch3">
<action name="Execute">
<command>sudo /usr/local/sbin/bluetooth_toggle</command>
</action>
</keybind>
<keybind key="XF86WLAN">
<action name="Execute">
<command>sudo /usr/local/sbin/wlan_toggle</command>
</action>
</keybind>
Discussion
Thank you for this one!
The script to switch brightness works when I use it manually. Somehow I'm still stuck with the keyboard-bindings as there's nothing going on when I type…but your script is very nice<!
@Nik,
hey, just use this:
https://launchpad.net/~voria/+archive/ppa
Thanks for these in depth instructions. I only have one problem and that is that I'm running Ubuntu. Are there instructions for where to save the file under a Ubuntu 11.04 system? Thank you very much in advance!
Thank you :).. Finally brightness is working on my NC10 Plus