Some multimedia keys on some keyboards are not seen at all in Ubuntu. If you go to System / Preferences / Keyboard Shortcuts and you try to set one of these key then nothing happens when you press them. Another test is to start xev and notice that no events are generated while hitting these keys. In most cases the problem is that the system is not mapping any key codes to the corresponding scan codes of these keys. To test this and also to find out the scan code just watch the kernel message log, in a terminal window type:
$ tail -f /var/log/messages
...and now hit those invisible keys.
A message in the log file will tell you to run setkeycode and it gives you the actual scan code. There are two things that you now have to figure out: an unused key code and hot to automatically run setkeycodes when the system starts.
To find an unused key code run the getkeycodes program as root. It will display a table with all the used key codes. It is a bit hard to find an unsued key code in this table, you can try grepping the getkeycodes output untill you find the right one:
$ sudo getkeycodes | grep 122
Now that you do have a unused key code you can run setkeycodes to set it and see if it works:
$ sudo setkeycodes <scan_code> <key_code>
Remeber that you do have the scan code from the kernel log message.
The problem is that on the next boot this setting will be lost. One solution is to write a short script that runs this setkeycodes command, put this script under /etc/init.d and link to it from /etc/rc2.d/. Here are the commands that will do this:
$ sudo vi /etc/init.d/keyfix.sh $ sudo chmod +x /etc/init.d/keyfix.sh $ sudo ln -s /etc/init.d/keyfix.sh /etc/rc2.d/keyfix.sh
The content of the keyfix.sh script should be something like:
Some multimedia keys on some keyboards are not seen at all in Ubuntu. If you go to System / Preferences / Keyboard Shortcuts and you try to set one of these key then nothing happens when you press them. Another test is to start xev and notice that no events are generated while hitting these keys. In most cases the problem is that the system is not mapping any key codes to the corresponding scan codes of these keys. To test this and also to find out the scan code just watch the kernel message log, in a terminal window type:
$ tail -f /var/log/messages
...and now hit those invisible keys.
A message in the log file will tell you to run setkeycode and it gives you the actual scan code. There are two things that you now have to figure out: an unused key code and hot to automatically run setkeycodes when the system starts.
To find an unused key code run the getkeycodes program as root. It will display a table with all the used key codes. It is a bit hard to find an unsued key code in this table, you can try grepping the getkeycodes output untill you find the right one:
$ sudo getkeycodes | grep 122
Now that you do have a unused key code you can run setkeycodes to set it and see if it works:
$ sudo setkeycodes <scan_code> <key_code>
Remeber that you do have the scan code from the kernel log message.
The problem is that on the next boot this setting will be lost. One solution is to write a short script that runs this setkeycodes command, put this script under /etc/init.d and link to it from /etc/rc2.d/. Here are the commands that will do this:
$ sudo vi /etc/init.d/keyfix.sh $ sudo chmod +x /etc/init.d/keyfix.sh $ sudo ln -s /etc/init.d/keyfix.sh /etc/rc2.d/S99keyfix
The content of the keyfix.sh script should be something like:
#!/bin/sh /usr/bin/setkeycodes e005 122
Technorati Tags: 


