星期三, 4月 15, 2009

How to change keycode or keybinding behavior

You can check whole hot key architecture here.
https://wiki.ubuntu.com/Hotkeys/Architecture

* Relative commands
1. input-utils package
a. lsinput: shows some information about each input device the kernel reports. This is useful to make sure you have the right device number for other testing.
b. input-events: tell you the events passing through the queue for any device
c. input-kbd: show you the keymap available for any device that provides keyboard events
2. acpi_listen: listen to acpi channel if the keycode send to acpi.
3. showkey : show the keycodes by -k and scancodes by -s parameter.
4. xev : show the key symbol in X environment like below.
5. xmodmap : GNOME mapping table
KeyRelease event, serial 33, synthetic NO, window 0x4400001,

. root 0x13b, subw 0x0, time 9487761, (321,324), root:(399,415), state 0x0, keycode 23 (keysym 0xff09, Tab), same_screen YES, XLookupString gives 1 bytes: (09) " " XFilterEvent returns: False

*How to find out the root cause of hot key
For kernel clarification
1. use "lsinput" to check which device file you used.
2. use "input-events 4" to listen if kernel get the right signal from device (4 means /dev/input/event"4")

For acpi clarification
3. excute "#showkey -s" to capture the keyboard signal.
4. Check the scancodes and refer to /usr/includes/linux/input.h file.
5. check the keycodes definition in /usr/share/acpi-support/key-constants
6. check the scripts file for acpi event in /etc/acpi/*.sh
7. you can use acpi-fakekey to simulate the keycode.

For GNOME system
8. use "xmodmap -pke" to check the key map
9. use "xev" to see which keycode or behavior under GNOME
10. Or you can use "gnome-keybinding-properties" to check the GNOME keybinding status.
============
gnome-keybinding-properties save the system default setting in following path
/var/lib/gconf/debian.defaults/%gconf-tree.xml
and save the user settings in
/home/juergen/.gconf/desktop/gnome/keybindings/"your-key-name"/%gconf.xml
============

---------------------------------------------------------------------------

For example: 0xe0 0x20 for fn-f9 audio mute binding code by showkey -s
xmodmap -pke (look for the available keycode number)
less /usr/share/X11/XKeysymDB (check which X Window default function)
setkeycodes e020 255 (that means keycode 255 will be 0xe0 0x20, change keybinding to keycode.)

For example: change keybinding 121->mute to 113->mute
$sudo xmodmap -e "keycode 113 = XF86AudioMute"
$xmodmap -pke | grep 113

For example: for acpi event
when acpi script needs 121 to mute, but mute button is 113.
add "$setkeycodes e020 121" to /etc/event.d/rc2 script section before exec line.
reboot and mute function keycode will change to 121.
modify /usr/share/acpi-support/key-constants 113 to 121



refer to the page
http://darkknight9.blogspot.com/2005/08/custom-keybinding-gnome.html
"Application/System Tools/Configuration Editor" for metacity "keybindings" function.

沒有留言: