How to shutdown the computer when hitting the Power button?

I have a Xubuntu Lucid 10.04 computer plugged in to my TV. I use the command line to administrate it.

Right now when I hit the power button it just opens a Logout screen.

How can I set it up so that I can shut it down by hitting the power button? I know it has something to do with acpi or acpid.

I want answers to be command-line only as I do not have any keyboard or mouse connected to that computer.


Edit:

Isn't there a way to modify the default behavior of the xfce4 power manager when pushing the power button?

Also instead of using the GUI to do so, can I do it by creating/modifying a configuration file?

jbowtie had an interesting answer but I cannot find the xfce4-power-manager.xml file. If someone knows where to find that file or how to create it, I would be interested.


When you hit the power button, the script /etc/acpi/powerbtn.sh is called. So one option is to modify this script to just call the shutdown script, bypassing the power management daemon. This works across all distributions and environments that I know of.

Since you're using Xubuntu, you can however just change the setting 'power-switch-action' in xfce4-power-manager.xml to the shutdown action - the default value is the ask action.


I found a solution. jbowtie put me on the right tracks. Kudos to him.

The problem was I did not have any xfce4-power-manager.xml file and I did not know exactly where to find the file and how to modify the file, but I found that I needed to copy the file from /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml and use xfconf-query to modify it properly.

The shutdown action for /xfce4-power-manager/power-button-action seemed to be 4.

Here's what I did:

cp /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml $HOME/.config/xfce4/xfconf/xfce-perchannel-xml
DISPLAY=:0.0 xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/power-button-action -s 4

You are indeed right about ACPI.

This forum post is exactly what you're looking for.

It details the steps you need to take far better than I ever could explain it :)

Edit: Basically, the solution was to install acpid.