Power button always shuts down the system in Linux Mint 16 KDE

Bug #1306912 reported by Mauro
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Linux Mint
Fix Released
Undecided
Unassigned
acpid
New
Undecided
Unassigned

Bug Description

This bug is related to bug #1184831.

In Linux Mint 16 KDE the shutdown button always shuts down the system, instead of respecting what I've chosen in my KDE settings.
The reason is in: /etc/acpi/powerbtn.sh
This scripts tests if there are some daemons running, more or less one for each of the main window managers (Cinnamon, Gnome, Mate, etc.): it it finds one, it doesn't do anything, otherwise it shuts down the system.
In particular it searches for kpower, which I suppose was a KDE daemon related to power management. However in my system I have no kpower at all. So, I added the following line:

PMS="$PMS kdeinit4"

just after the other "PMS=..." definitions and now the system behaves as expected.

However, I'm not sure if checking for kdeinit4 is the best choice, or if I should better check for another more appropriate running process.

Mauro (mauromol)
affects: acpid (Ubuntu) → linuxmint
Revision history for this message
Clement Lefebvre (clementlefebvre) wrote :

It looks ok in Mint 17.

The script uses qdbus and checks for powerdevil.

Revision history for this message
Clement Lefebvre (clementlefebvre) wrote :

#!/bin/sh
# /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

# If logind is running, it already handles power button presses; desktop
# environments put inhibitors to logind if they want to handle the key
# themselves.
if pidof systemd-logind >/dev/null; then
    exit 0
fi

# 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`
                fi
        fi
        if [ x"$user" != x"" ]; then
                userhome=`getent passwd $user | cut -d: -f6`
                export XAUTHORITY=$userhome/.Xauthority
        else
                export XAUTHORITY=""
        fi
        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="cinnamon-settings-daemon gnome-settings-daemon kpowersave xfce4-power-manager"
PMS="$PMS guidance-power-manager.py dalston-power-applet"
PMS="$PMS mate-settings-daemon"
PMS="$PMS unity-settings-daemon"

if pidof x $PMS > /dev/null; then
        exit
elif test "$XUSER" != "" && pidof dcopserver > /dev/null && test -x /usr/bin/dcop && /usr/bin/dcop --user $XUSER kded kded loadedModules | grep -q klaptopdaemon; then
        exit
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
                        exit
                fi
        fi
fi

# If all else failed, just initiate a plain shutdown.
/sbin/shutdown -h now "Power button pressed"

Changed in linuxmint:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.