# 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.
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"
#!/bin/sh powerbtn. sh
# /etc/acpi/
# 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.
startx= `pgrep -n startx`
user= `ps -o user --no-headers $startx`
userhome= `getent passwd $user | cut -d: -f6`
export XAUTHORITY= $userhome/ .Xauthority
export XAUTHORITY=""
# 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
if [ x"$startx" != x"" ]; then
fi
fi
if [ x"$user" != x"" ]; then
else
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 acpi-support/ policy- funcs' file.
# handles suspend/resume requests, let them handle policy This is effectively
# the same as 'acpi-support's '/usr/share/
[ -r /usr/share/ acpi-support/ power-funcs ] && getXconsole settings- daemon gnome-settings- daemon kpowersave xfce4-power- manager" power-manager. py dalston- power-applet" daemon" daemon"
PMS="cinnamon-
PMS="$PMS guidance-
PMS="$PMS mate-settings-
PMS="$PMS unity-settings-
if pidof x $PMS > /dev/null; then
kded4pid= $(pgrep -n -u $XUSER kded4)
dbusaddr= $(su - $XUSER -c "grep -z DBUS_SESSION_ BUS_ADDRESS /proc/$ kded4pid/ environ" )
exit
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
if test "$kded4pid" != ""; then
if test "$dbusaddr" != "" && su - $XUSER -c "export $dbusaddr; qdbus org.kde.kded" | grep -q powerdevil; then
fi
fi
fi
# If all else failed, just initiate a plain shutdown.
/sbin/shutdown -h now "Power button pressed"