Blame samples/powerbtn/powerbtn.sh.old
|
Packit Service |
26469c |
#!/bin/sh
|
|
Packit Service |
26469c |
# /etc/acpi/powerbtn.sh
|
|
Packit Service |
26469c |
# Taken from the 11/14/2008(ish) version from Debian.
|
|
Packit Service |
26469c |
# Power Button event handler.
|
|
Packit Service |
26469c |
# Checks to see if gnome or KDE are already handling the power button.
|
|
Packit Service |
26469c |
# If not, initiates a plain shutdown.
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
# This is an older version from Debian that does not handle KDE4.
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
# Skip if we are in the middle of resuming. Otherwise we may power down the
|
|
Packit Service |
26469c |
# system as it is coming back up.
|
|
Packit Service |
26469c |
# See 98-acpi-unlock.sh and 05-acpi-lock.sh in Debian.
|
|
Packit Service |
26469c |
test -f /var/lock/acpisleep && exit 0
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
# If gnome-power-manager, kpowersave or klaptopdaemon are running...
|
|
Packit Service |
26469c |
if pidof gnome-power-manager kpowersave > /dev/null ||
|
|
Packit Service |
26469c |
(pidof dcopserver > /dev/null && test -x /usr/bin/dcop && /usr/bin/dcop kded kded loadedModules | grep -q klaptopdaemon) ; then
|
|
Packit Service |
26469c |
# Let them handle the power button.
|
|
Packit Service |
26469c |
exit
|
|
Packit Service |
26469c |
fi
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
# If KDE is running...
|
|
Packit Service |
26469c |
if ps -Af | grep -q '[k]desktop' && pidof dcopserver > /dev/null && test -x /usr/bin/dcop ; then
|
|
Packit Service |
26469c |
# Ask it to logout.
|
|
Packit Service |
26469c |
KDESES=`pidof dcopserver | wc -w`
|
|
Packit Service |
26469c |
if [ $KDESES -eq 1 ] ; then
|
|
Packit Service |
26469c |
# single KDE session -> ask user
|
|
Packit Service |
26469c |
/usr/bin/dcop --all-sessions --all-users ksmserver ksmserver logout 1 2 0
|
|
Packit Service |
26469c |
exit 0
|
|
Packit Service |
26469c |
else
|
|
Packit Service |
26469c |
# more than one KDE session - just send shutdown signal to all of them
|
|
Packit Service |
26469c |
/usr/bin/dcop --all-sessions --all-users ksmserver ksmserver logout 0 2 0 && exit 0
|
|
Packit Service |
26469c |
fi
|
|
Packit Service |
26469c |
fi
|
|
Packit Service |
26469c |
|
|
Packit Service |
26469c |
# Initiate a plain shutdown.
|
|
Packit Service |
26469c |
/sbin/shutdown -h now "Power button pressed"
|
|
Packit Service |
26469c |
|