Jonathan Underwood wrote:
I have a USB keyboar which I sometimes plug into my laptop to use. It
is one of those with a power on/off button on it, which is supposed to
power on/off the computer. This button doesn't do anything though.
Pressing it doesn't yield any message in the output of dmesg. Does
anyone have any hints on how to get this button to act as a power
on/off button for my laptop? I am guessing this is a lost cause due to
lack of bios support, but thought I' ask anyway.
It's certainly possible. The first step is to run xev from the command
line whilst in X. It'll open a little window. Make sure the window is
selected and you can see the terminal output. Press the button a few
times and remember the keycode it produces. The next step is to assign
the keycode to a key symbol. One way to think about this is that every
key produces a raw value, but you need to assign that value to a symbol.
Most keys are done automatically for you, eg the raw value for the M
key is assigned the m symbol but we're doing this manually for this
special key.
As root, edit the file /etc/X11/Xmodmap and insert the following:
keycode <value> = XF86PowerOff
Obviously, replace <value> with the keycode you got earlier. You can
either relogin to enable it, or type xmodmap /etc/X11/Xmodmap to do it
instantly. XF86PowerOff is the symbol. Now depending on your desktop,
this might be enough, or you could try XF86PowerDown instead.
If that doesn't work, (some symbols are automatically handled by
default) at least you are able to assign that key as a hotkey in your
desktop environment for powering off, logging out, whatever.
Sorry if my explanation is as clear as mud :)
--
Ian Chapman.