Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
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 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?
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.
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.