Enable extra keys on a laptop Filed Under: Linux & BSD
Introduction
This tutorial is for enabling the extra keys that you may find in laptops (like the omnitouch buttons found in HP laptops). To be able to use these keys will need to map the code generated by those keys to a function number, e.g F22, F23. After the key is mapped the rest is piece of cake. So lets do it.
Getting the code generated
To find the code that the key is generating will need to use the application xev from the command line.
Once the application is running just type the key while the window is active and check the output in the command line. There you will see a lot of events but the important ones are the KeyPress and KeyRelease events. In those events you will see the keycode and to which value is mapped. Normally the keys we want to enable will be mapped to none.
Mapping the keycode to a function
To map the keycode to a function we will edit the file ~/.xmodmaprc. There we will put in each line the keycode and to which function maps. For example:
keycode 236 = F13
You can find the .xmodmaprc that is in my laptop here if you want to have a look (the laptop is an HP nx9005).
To load the file so Linux can start using the keys you need to execute the following command.
xmodmap .xmodmaprc
Loading the xmodmaprc at login
OK so at the moment we have the keys loaded so Linux can used them but every time we login will have to execute the command. You’ll need to modify the following files depending on the login you are using:
Logging through GDM
If you login through GDM you will need to modify the file /etc/gdm/Xsession. In that file you’ll need to check that the variable usermodmap
points to the right location of your xmodmaprc file.
Logging through the terminal
If you logging through the terminal just edit your .bash_profile file to contain the following lines:
if [ ! -z "${DISPLAY:-}" -a -f $HOME/.xmodmaprc ]; then
xmodmap $HOME/.xmodmaprc
fi
- Permalink
- Alberto Diaz
- 28 Feb 2007 9:00 AM
- Comments (0)