Xfce keybindings

From OLPC
Revision as of 01:57, 21 June 2008 by Metal.lunchbox (talk | contribs) (New page: Xfce is a user frontend installed on many OLPC laptops to replace or function alongside the default Sugar user interface. When it is installed on an OLPC laptops the screen brightn...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Xfce is a user frontend installed on many OLPC laptops to replace or function alongside the default Sugar user interface. When it is installed on an OLPC laptops the screen brightness and rotation buttons as well as the volume buttons no longer function as expected. While it may appear complicated the following instuctions should make these keys functional again. These instructions may seem complicated at first but anyone with a working knowledge of the terminal should be able to use them.

Xbindkeys

The first step to making the keys work the way you want them to is to install a small application called Xbindkeys. In the terminal use the following commands:

 $ su
 # yum install xbindkeys

Follow the simple install procedures and create a keybindings file which you will be editing thoughout the rest of this tutorial:

 # xbindkeys –defaults > /home/olpc/.xbindkeysrc

In order to map the keys to the appropriate action we must now first discover the index for each of the concerned keys. In the instructions that follow, the correct key indexes are included so you don't have to perform this step it is included here in case you want to map out other keys to additional actions. The command "xbindkeys -k" followed by pressing one key will give the keycode for that key. For the increase volume button for example the keycode is c:96

To edit the keybindings file that we have created use any text editor you please. Nano is easy to use so we'll use it:

 # nano /homr/olpc/.xbindkeysrc

The format for adding a keybinding to this file is one line with a hash " # " followed by a comment describing what the keybinding will do, a second line with the command to be executed in quotes, and a third line with the keycode.

Adjust screen brightness buttons

Because of the restricted access to the backlight adjustment program this is the most complicated part of the keybinding tutorial. Start by creating a script to adjust screen brightness when called from xbindkeys:

 File: /usr/bin/adjust_brightness.sh
# The first argument is whether to increase the brightness (+) or
# decrease the brightness (-).
# The second argument is optional and indicates the step size when
# increasing or decreasing the brightness. The default is 1.
if [ $# -eq 0 ]; then exit 1; fi
bright_file="/sys/class/backlight/dcon-bl/brightness"
mbright_file="/sys/class/backlight/dcon-bl/max_brightness"
while read line; do
brightness=$line
done < <(cat "$bright_file")
while read line; do
max_brightness=$line
done < <(cat "$mbright_file")
step=1
if [ $# -gt 1 ]; then
step=$2
fi
declare -i brightness
if [ $1 = "-" ]; then
if [ $brightness -ne 0 ]; then
brightness=$brightness-$step;
echo $brightness > /sys/class/backlight/dcon-bl/brightness
fi
else
if [ $brightness -ne $max_brightness ]; then
brightness=$brightness+$step;
echo $brightness > $bright_file
fi
fi

Don't worry if you don't understand the above script. You can just copy and paste the contents into the file you create when using the following command:

 # nano /usr/bin/adjust_brightness.sh

Now you must make this file executable:

 # chmod +x /usr/bin/adjust_brightness.sh

Open the keybindings file and add have the "dim" (c:75) and "bright" (c:76) keys execute the above script:

 # nano /home/olpc/.xbindkeysrc

and paste the following before "End of Xbindkeys configuration" :

 ## Reduce brightness
 "/usr/bin/adjust_brightness.sh -" 
 c:75
 
 ## Increase brightness
 "/usr/bin/adjust_brightness.sh +" 
 c:76

Adjust volume buttons

Rotate screen button

Other options

Many applications use F11 to toggle fullscreen. You can map your frame button in the top-right corner of the keyboard for this with a simple command:

 # xmodmap -e 'keycode 147=F11'

you can use this method to link F-keys to the rest of the unused top-row of keys if you like. This will only last for the current session. To make the results last simply add the command to Autostarted Applications or preferably to the startup script you created above- "/home/olpc/.xfce4_startup"

Reference

  • Much of this page is gleaned from the "Xfce?" thread on the OLPC news forums
  • Most of the instructions are based on work by OLPC news forum user Frihet