(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: Quote:
|
Use ACPI
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. Daniel |
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' event=button/power.* action=/etc/acpi/onButtonPress-Power.sh 7) An example of /etc/acpi/onButtonPress-Power.sh #!/bin/sh # /etc/acpi/onButtonPress-Power.sh #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/onButtonPress-Power.sh |
sadarax,
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. Daniel |
All times are GMT -5. The time now is 06:30 PM. |