How-to specify power button to do a 'shutdown -h now' instead of graphical shutdown menu?

19,880

That's simple enough. When you press the power button a ACPI event triggers the script at /etc/acpi/powerbtn.sh.

You can edit that to just run shutdown -h now as the first thing so it looks like:

#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.

/sbin/shutdown -h now "Power button pressed"
exit 0

# leave the old code below (in case you want to revert!)
Share:
19,880

Related videos on Youtube

719016
Author by

719016

Updated on September 18, 2022

Comments

  • 719016
    719016 almost 2 years

    I would like to specify that when I press the power button in my laptop, a 'shutdown -h now' command is sent, instead of bringing up the graphical shutdown menu. How can I do that on Ubuntu 11.10?

  • Bruno Pereira
    Bruno Pereira over 12 years
    Move your answer to the other one and we can close this as a dupe.