~ubuntu-branches/ubuntu/lucid/acpid/lucid-updates

« back to all changes in this revision

Viewing changes to debian/powerbtn.sh

  • Committer: Bazaar Package Importer
  • Author(s): Michael Meskes
  • Date: 2009-11-17 14:50:01 UTC
  • mfrom: (2.1.12 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091117145001-y5hevyg7gcg6uwjk
Tags: 1.0.10-4
Updated netlink patch to version 6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# Initiates a shutdown when the power putton has been
4
4
# pressed.
5
5
 
 
6
# getXuser gets the X user belonging to the display in $displaynum.
 
7
# If you want the foreground X user, use getXconsole!
 
8
getXuser() {
 
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`
 
14
                fi
 
15
        fi
 
16
        if [ x"$user" != x"" ]; then
 
17
                userhome=`getent passwd $user | cut -d: -f6`
 
18
                export XAUTHORITY=$userhome/.Xauthority
 
19
        else
 
20
                export XAUTHORITY=""
 
21
        fi
 
22
        export XUSER=$user
 
23
}
 
24
 
6
25
# Skip if we just in the middle of resuming.
7
26
test -f /var/lock/acpisleep && exit 0
8
27
 
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.
12
 
 
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.
 
31
 
 
32
getXconsole
 
33
PMS="gnome-power-manager kpowersave xfce4-power-manager"
 
34
PMS="$PMS guidance-power-manager.py dalston-power-applet"
 
35
 
 
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
14
39
    exit
15
40
fi
16
41