Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I have a Genius K627 Keyboard with Power, Sleep and Wake buttons. ACPI is unsupported on my computer, but it can turn off its power supply when the system halts (PM is ok). I would like to bind the Power key on the keyboard to execute the /sbin/halt command. What I already know is that I can specify an event in inittab (kbrequest) that would execute a command. What I don't know how I can make my system receive pressing Power button as a kbrequest. The scancodes of Power button on the keyboard (by showkey): 0x74 0xf4
This is the line I was talking about in my inittab:
I think I should edit /etc/console/boottime.kmap.gz but don't know how I could insert this scancode into it.
First, I recommend that you bind the key(s) to the proper shutdown command, /sbin/shutdown, rather than /sbin/halt. The halt command is the software equivalent of pulling the power cord out of your computer. It could eventually lead to data corruption including corruption of the partition tables On the disk.
You didn't say what's your distro,but wherever you have to look for the file to edit and it could be for example in;
I have Debian Sarge.
Originally Posted by alan_ri
/etc/kbd/default.map.gz or in /etc/console-tools
try to add these lines;
keycode 74 = Shutdown
keycode 74 = KeyboardSignal
Tried this one, but had to replace 74 to 116, because 74(hex) = 116(dec) and boottime.kmap.gz stores keycodes decimally. I didn't even need keycode 74 = Shutdown. Anyway, I have successfully bound the power key to the shutdown command (using keycode 116 = Shutdown and the inittab line). Thanks for your help, alan_ri!
By the way, I found some lines that were already referred to keycode 116, I commented them:
#keycode 116 = Do
# altgr control keycode 116 = VoidSymbol
# altgr alt keycode 116 = VoidSymbol
Any reason why you're still running Sarge? It's a bit long in the tooth now.
You're damn right, but nowadays linux (all of them not just debian) works by a principle: the newer distro the slower code. I tried etch and sid on my Pentium I 233MHz but they were slower, moreover Sarge is slightly slower than its ancestor, Woody. I don't know why this kind of era is good. I'm supposing some background-agreement with hardware-manufacturers. They bring a huge support to Linux, but developers (including kernel developers) must write inefficient code to make system administrators keep buying new hardware devices over and over again even if they don't need them. I don't need more than my Pentium I server is capable of: watching streaming TV (mplayer), ftp server, bittorrent, samba, listening to radio and music from the disk, router etc.
It's called layering. mknod replaced by udev, supplimented by dbus, yadda yadda yadda. You can turn off most of those layers and still have a functional system though. i.e. mknod still works just fine. (as long as udev is put to bed). If your ps output is longer than 24 lines, you've got too much running IMO.
And yet you're asking about a layer to hotkey a shutdown. If you're system was acpi, you could rig up some acpi events. Those might still work on an APM system(ancient). I've got one setup on my laptop to power down when the red button is pushed. Some of my desktops have the same. X locks up, well that power button still triggers a proper shutdown. i.e. no fsck at reboot. Which on a 1TB allocation takes a while.
Basically you might be able to run acpid, and setup some scripts in /etc/acpi/ even though your system doesn't have acpi. apt-get install acpid (powerbtn.sh comes with it on my system) It might require some customization to use the keyboard power button in addition to (or instead of) the computers power button. But the basic functionality is already in place.
It's called layering. mknod replaced by udev, supplimented by dbus, yadda yadda yadda.
I'm talking about the binaries getting slower and slower, not just the layers. Unfortunately my motherboard doesn't support ACPI at all, already tried acpid for the purpose, no success. But acpid is also a process and uses memory, but this way there's no daemon, only the halt command runs when I press the power off button on the keyboard.