LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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.

Notices

Reply
 
Search this Thread
Old 07-08-2009, 07:42 AM   #1
stringZ
Member
 
Registered: Dec 2006
Posts: 42

Rep: Reputation: 15
Keyboard Power Button to shutdown my computer


Dear Linuxofrum users!

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:
Code:
ce:12345:kbrequest:/sbin/halt
I think I should edit /etc/console/boottime.kmap.gz but don't know how I could insert this scancode into it.

Anyone who could help me?

Thanks in advance
stringZ
 
Old 07-08-2009, 08:29 AM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
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.
 
Old 07-08-2009, 09:30 AM   #3
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
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;

/etc/kbd/default.map.gz or in /etc/console-tools

try to add these lines;

Code:
keycode 74 = Shutdown
keycode 74 = KeyboardSignal
and in /etc/inittab:
Code:
kb:12345:kbrequest:/sbin/shutdown -t1 -h now
 
Old 08-01-2009, 04:28 AM   #4
stringZ
Member
 
Registered: Dec 2006
Posts: 42

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by alan_ri View Post
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.

Quote:
Originally Posted by alan_ri View Post

/etc/kbd/default.map.gz or in /etc/console-tools

try to add these lines;

Code:
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:
Code:
#keycode 116 = Do
#       altgr   control keycode 116 = VoidSymbol
#       altgr   alt     keycode 116 = VoidSymbol
What is this?
 
Old 08-03-2009, 05:45 AM   #5
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
Well, void means zero, nada, so that means that that key wasn't set, just like by default it isn't in Linux.
 
Old 08-03-2009, 05:50 AM   #6
jdkaye
Senior Member
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 4,958

Rep: Reputation: Disabled
Quote:
Originally Posted by stringZ View Post
I have Debian Sarge.
Any reason why you're still running Sarge? It's a bit long in the tooth now.
jdk
 
Old 10-11-2009, 12:12 PM   #7
stringZ
Member
 
Registered: Dec 2006
Posts: 42

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jdkaye View Post
Any reason why you're still running Sarge? It's a bit long in the tooth now.
jdk
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.

Regards
stringZ
 
Old 10-12-2009, 10:49 AM   #8
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 1,554

Rep: Reputation: 241Reputation: 241Reputation: 241
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.
 
Old 10-16-2009, 06:23 AM   #9
stringZ
Member
 
Registered: Dec 2006
Posts: 42

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Shadow_7 View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Power Button for Shutdown gokul Linux - Hardware 4 01-24-2004 01:40 PM
ACPI: shutdown computer by pushing power button... elluva Mandriva 10 12-15-2003 04:57 AM
RH 9 orderly shutdown by power button? geezjan Red Hat 1 09-19-2003 11:01 AM
Shutdown with power button hriosm Linux - Hardware 4 06-06-2003 03:43 PM
Shutdown routine with power button bfought Linux - Newbie 2 09-09-2002 07:23 PM


All times are GMT -5. The time now is 09:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration