I have a (seemingly rather exotic) Dell Latitude XT2 notebook running Lubuntu 12.04, fresh install. Tried to get the power button to work as expected (opening the logout dialog lubuntu-logout), but no success: power button does nothing but forced power-off on long press.

The power button itself is detected and works. In xfce4-power-manager-settings, when I set the power button action from "Ask" (= open lubuntu-logout) to "Shutdown", the laptop shuts down successfully; pressing the power button is recognized and processed correctly.

Edit: I removed a bunch of info from the question, as it seems not to be related to the problem.


Install acpi and acpi-support, if not already installed.

  • Go to /etc/acpi/events.
  • There should be a file named powerbtn (if not, make it). The contents of the file in my installation are:
# /etc/acpi/events/powerbtn
# This is called when the user presses the power button and calls
# /etc/acpi/powerbtn.sh for further processing.

# Optionally you can specify the placeholder %e. It will pass
# through the whole kernel event message to the program you've
# specified.

# We need to react on "button power.*" and "button/power.*" because
# of kernel changes.

event=button[ /]power
  • You can associate an action with the powerbutton by editing the action variable in this file.
  • In my installation, the contents of /etc/acpi/powerbtn.sh are:
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.

[ -r /usr/share/acpi-support/power-funcs ] && . /usr/share/acpi-support/power-funcs

# getXuser gets the X user belonging to the display in $displaynum.
# If you want the foreground X user, use getXconsole!
getXuser() {
        user=`pinky -fw | awk '{ if ($2 == ":'$displaynum'" || $(NF) == ":'$displaynum'" ) { print $1; exit; } }'`
        if [ x"$user" = x"" ]; then
                startx=`pgrep -n startx`
                if [ x"$startx" != x"" ]; then
                        user=`ps -o user --no-headers $startx`
        if [ x"$user" != x"" ]; then
                userhome=`getent passwd $user | cut -d: -f6`
                export XAUTHORITY=$userhome/.Xauthority
                export XAUTHORITY=""
        export XUSER=$user

# Skip if we just in the middle of resuming.
test -f /var/lock/acpisleep && exit 0

# If the current X console user is running a power management daemon that
# handles suspend/resume requests, let them handle policy This is effectively
# the same as 'acpi-support's '/usr/share/acpi-support/policy-funcs' file.

[ -r /usr/share/acpi-support/power-funcs ] && getXconsole
PMS="gnome-settings-daemon kpowersave xfce4-power-manager"
PMS="$PMS guidance-power-manager.py dalston-power-applet"

if pidof x $PMS > /dev/null; then
elif test "$XUSER" != "" && pidof dcopserver > /dev/null && test -x /usr/bin/dcop && /usr/bin/dcop --user $XUSER kded kded loadedModules | grep -q klaptopdaemon; then
elif test "$XUSER" != "" && test -x /usr/bin/qdbus; then
        kded4pid=$(pgrep -n -u $XUSER kded4)
        if test "$kded4pid" != ""; then
                dbusaddr=$(su - $XUSER -c "grep -z DBUS_SESSION_BUS_ADDRESS /proc/$kded4pid/environ")
                if test "$dbusaddr" != "" && su - $XUSER -c "export $dbusaddr; qdbus org.kde.kded" | grep -q powerdevil; then

# If all else failed, just initiate a plain shutdown.
/sbin/shutdown -h now "Power button pressed"
  • I do not have a folder /etc/acpi. o.O – dyp Sep 26 '12 at 17:49
  • try creating one. – green Sep 26 '12 at 17:58
  • Already done ^^ using just the last line of your script (which hopefully doesn't break it) -- and still nothing (yes, I rebooted). – dyp Sep 26 '12 at 18:01
  • acpid was not installed. Installed it, yet no difference. – dyp Sep 26 '12 at 18:11
  • try /etc/init.d/acpid restart – green Sep 26 '12 at 18:24

It seems to be a known bug in Lubuntu. In xfce4-power-manager-settings, there are several actions to select for the Power Button being pressed. When you select "Shut Down", it works as expected, but when you select "Ask", nothing happens.

A workaround is in the comment #10. It works for me. Seems there's an underlying problem between xfce4 and LXDE.

You can create the same behaviour with an (additional) acpi daemon, like green7 said. The version in his answer shuts down the PC w/o a dialog, but we discussed in chat that you can start lubuntu-logout from the script instead of simply shutting down the computer. This needs some work, though, as you have to start the logout application as a user who is allowed to connect to X, and provide the necessary environment variables (like $DISPLAY). As the env variables seem to vary between the distros, I think you had to look them up carefully for LXDE.

The workaround link was broken, but seems to be restored (although the site is slow). Here's the gist:

login to your LXDE session (Lubuntu settings in the combo box)
open a terminal
kill xfce4-power-manager: xfce4-power-manager -q
openbox --reconfigure
start xfce4-power-manager: xfce4-power-manager


My opinion is there is a conflict between xfce4-power-manager and LXDE and order in which these applications start seems to be important... strange...

  • The link is broken... fantastic. – klatzib Feb 6 '16 at 17:20
  • @klatzib Sorry, I should have known better and included the info in my answer. Please note that I did not have that issue in more recent versions of Lubuntu. – dyp Feb 6 '16 at 17:49
  • @klatzib It might have been this workaround, but I can't really remember. – dyp Feb 6 '16 at 17:58
  • @klatzib The site is back online :D (kinda, it moved and there's a redirect now...) – dyp Mar 18 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.