Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


  Search this Thread
Old 04-03-2007, 12:21 AM   #1
Registered: Sep 2005
Distribution: Ubuntu
Posts: 249

Rep: Reputation: 30
(SOLVED) Power button map to shutdown command

I have a computer I would like to be able to turn off by merely pressing the power button, and having Linux respond by initiating a proper shutdown command and sequence. Is this possible to do and how would I do it?

The System Spec's:
MotherBoard: Abit Kt7 Raid
CPU: AMD Athlon T-Bird 1200 MHz
RAM: SD-PC-133 512MB
Video Card: nVidia Riva TNT2 32MB
Sound: Sound Blaster Live!
TV Capture Card: Hauppauge PVR-150
Distro: KnoppMyth:
* Release 5 E50
* MythTV: 0.20
Desktop Environment: FluxBox
Kernel: 2.6.18-chw-13

Last edited by sadarax; 04-03-2007 at 01:34 AM.
Old 04-03-2007, 12:40 AM   #2
Registered: May 2006
Posts: 64

Rep: Reputation: 15

Hi there,

I was curious about this, too, so trying to figure out how to help you prompted me to learn a bit. Read this relevant LQ post and answer. I have also found the Gentoo wiki to be extremely helpful no matter what distro you run (I run Slackware). I found an article describing the details that should be applicable here.

Good luck, and let us know if this helped.

Old 04-03-2007, 01:35 AM   #3
Registered: Sep 2005
Distribution: Ubuntu
Posts: 249

Original Poster
Rep: Reputation: 30
Thanks a ton Murali. The Gentoo wiki was especially helpful. I managed to get everything working. Here is a quick tutorial for what I did on my Debian based system.

1) Check to see that the button is registered:

dmesg | grep '^ACPI:'

If you get any output, you have ACPI compiled in

2) Registering the power button as an ACPI event

cat /var/log/dmesg | grep '^ACPI: Power Button'

If you get output, then your power button is registered. If not, then you'll need to either a) recompile the kernel with button registration engaged, or b) load the button module.

3) Load the button module

Ensure that you're kernel has button support available. Find the 'button.ko' file.

Load the button module to test for errors:
insmod /location/of/button.ko
lsmod | grep button

If you receive no errors and lsmod returns information, then the module has been successfully inserted.

4) Load 'button' module on startup

Ensure that you have the 'button' kernel module loaded/loading on system startup. In Debian, you do this by adding to the /etc/modules.

5) Make sure ACPID is on the system

apt-get install acpid

If the installation does not automatically add startup and shutdown links in the /etc/rc*.d directores, you should manually add them.

6) ACPI-Events

Go to the directory /etc/acpi/events, if it does not exist, create it.
Create the file 'power' with:
vim /etc/acpi/events/power

Add this to 'power'

7) An example of /etc/acpi/

# /etc/acpi/
#Shutdown when the power button is pressed

logger "Power button pressed -- shutting system down"
/sbin/shutdown -h now

8) Make executable. Don't forget!

chmod 750 /etc/acpi/
Old 04-04-2007, 08:35 AM   #4
Registered: May 2006
Posts: 64

Rep: Reputation: 15

Glad to hear it! I've been making use of the community for help for a long time, it seems; it's nice to have been able to help. And I've learned something myself.



acpi, button, command, howto, map, power, shutdown

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
disable shutdown by press the power button nickraj General 8 03-02-2007 11:16 PM
Power Button for Shutdown gokul Linux - Hardware 4 01-24-2004 12:40 PM
RH 9 orderly shutdown by power button? geezjan Red Hat 1 09-19-2003 10:01 AM
Shutdown with power button hriosm Linux - Hardware 4 06-06-2003 02:43 PM
Shutdown routine with power button bfought Linux - Newbie 2 09-09-2002 06:23 PM > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 02:57 PM.

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