3
3
# Initiates a shutdown when the power putton has been
6
# getXuser gets the X user belonging to the display in $displaynum.
7
# If you want the foreground X user, use getXconsole!
9
user=`pinky -fw | awk '{ if ($2 == ":'$displaynum'" || $(NF) == ":'$displaynum'" ) { print $1; exit; } }'`
10
if [ x"$user" = x"" ]; then
11
startx=`pgrep -n startx`
12
if [ x"$startx" != x"" ]; then
13
user=`ps -o user --no-headers $startx`
16
if [ x"$user" != x"" ]; then
17
userhome=`getent passwd $user | cut -d: -f6`
18
export XAUTHORITY=$userhome/.Xauthority
6
25
# Skip if we just in the middle of resuming.
7
26
test -f /var/lock/acpisleep && exit 0
9
# If gnome-power-manager, kded4, dalston-power-applet or xfce4-power-manager
10
# are running, let them handle policy This is effectively the same as
11
# 'acpi-support's '/usr/share/acpi-support/policy-funcs' file.
13
if pidof gnome-power-manager kded4 dalston-power-applet xfce4-power-manager > /dev/null; then
28
# If the current X console user is running a power management daemon that
29
# handles suspend/resume requests, let them handle policy This is effectively
30
# the same as 'acpi-support's '/usr/share/acpi-support/policy-funcs' file.
33
PMS="gnome-power-manager kpowersave xfce4-power-manager"
34
PMS="$PMS guidance-power-manager.py dalston-power-applet"
36
if pidof x $PMS > /dev/null ||
37
( test "$XUSER" != "" && pidof dcopserver > /dev/null && test -x /usr/bin/dcop && /usr/bin/dcop --user $XUSER kded kded loadedModules | grep -q klaptopdaemon) ||
38
( test "$XUSER" != "" && test -x /usr/bin/qdbus && test -r /proc/$(pidof kded4)/environ && su - $XUSER -c "eval $(echo -n 'export '; cat /proc/$(pidof kded4)/environ |tr '\0' '\n'|grep DBUS_SESSION_BUS_ADDRESS); qdbus org.kde.kded" | grep -q powerdevil) ; then