threetimes
December 9th, 2008, 05:30 AM
I have a keyboard* with a shutdown-button, and it is conected to my server.
If I press and release this button with showkeys running I get this:
showkeys -s
kb mode was UNICODE
press any key (program terminates after 10s of last keypress)...
0xe0 0x32
0xe0 0xb2
showkeys -k
kb mode was UNICODE
press any key (program terminates after 10s of last keypress)...
0x00 0x81 0xac
0x80 0x81 0xac
I think I want a little deamon running as root (or any other user able to shutdown the server), that checks for the above scancodes/keycodes and execute a script** when I release the button.
* I actually disassembled the keyboard like this (http://martybugs.net/electronics/kbdleds.cgi), and the standby and shutdown buttons are the only buttons left now. The standby button doesn't generate any scancode, so I ignore it.
** The script first does a SOS and thet shuts down.
# first: .../---/... (morse...)
# then poweroff
# ...
echo -ne "\a"
sleep 0.2
echo -ne "\a"
sleep 0.2
echo -ne "\a"
sleep 0.6
# ---
echo -ne "\a"
sleep 0.35
echo -ne "\a"
sleep 0.35
echo -ne "\a"
sleep 0.6
# ...
echo -ne "\a"
sleep 0.2
echo -ne "\a"
sleep 0.2
echo -ne "\a"
sleep 0.6
sudo poweroff
If I press and release this button with showkeys running I get this:
showkeys -s
kb mode was UNICODE
press any key (program terminates after 10s of last keypress)...
0xe0 0x32
0xe0 0xb2
showkeys -k
kb mode was UNICODE
press any key (program terminates after 10s of last keypress)...
0x00 0x81 0xac
0x80 0x81 0xac
I think I want a little deamon running as root (or any other user able to shutdown the server), that checks for the above scancodes/keycodes and execute a script** when I release the button.
* I actually disassembled the keyboard like this (http://martybugs.net/electronics/kbdleds.cgi), and the standby and shutdown buttons are the only buttons left now. The standby button doesn't generate any scancode, so I ignore it.
** The script first does a SOS and thet shuts down.
# first: .../---/... (morse...)
# then poweroff
# ...
echo -ne "\a"
sleep 0.2
echo -ne "\a"
sleep 0.2
echo -ne "\a"
sleep 0.6
# ---
echo -ne "\a"
sleep 0.35
echo -ne "\a"
sleep 0.35
echo -ne "\a"
sleep 0.6
# ...
echo -ne "\a"
sleep 0.2
echo -ne "\a"
sleep 0.2
echo -ne "\a"
sleep 0.6
sudo poweroff