/usr/sbin/pmi is in powermanagement-interface 0.3.20.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | #!/bin/bash
# This is the ACPI version of the shell version of PMI
# calling convention: pmi <event>
command="$1"
event="$2"
usage () {
echo "Usage: $0 query|action <event>" >&2
echo " $0 capabilities" >&2
exit 254
}
query () {
[ ! -z "$1" ] && event="$1"
case "$event" in
suspend|sleep)
if grep -q ' /host fuse' /proc/mounts; then
# Disallow suspend when we're mounting /
# from a loopback image on a fuse
# filesystem.
result=1
else
pm-is-supported --suspend && result=0 || result=1
fi
;;
hibernate)
if grep -q ' /host fuse' /proc/mounts || \
! swapon -s | tail -n +2 | awk '$2 == "file" { exit 1 }'; then
# Disallow hibernate when we're mounting /
# from a loopback image on a fuse
# filesystem, or when a swap file is active.
result=1
elif [ -f /var/run/do-not-hibernate ]; then
result=1
else
pm-is-supported --hibernate && result=0 || result=1
fi
;;
*)
result=1
echo "No such event found" >&2
;;
esac
}
run () {
case "$event" in
suspend|sleep)
[ -f /var/lock/acpisleep ] && exit 0
dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0
;;
hibernate)
[ -f /var/lock/acpisleep ] && exit 0
[ -f /var/run/do-not-hibernate ] && echo "Default kernel has been upgraded" >&2 && exit 1
dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate
;;
restart)
[ -f /var/lock/acpisleep ] && exit 0
shutdown -r now
;;
shutdown)
[ -f /var/lock/acpisleep ] && exit 0
shutdown -h now
;;
esac
}
capabilities () {
for i in "hibernate" "suspend"; do
query $i
[ $result -eq 0 ] && caps="$caps $i"
done
echo $caps
}
case "$command" in
query)
query $event
exit $result
;;
action)
run $event
;;
capabilities)
capabilities
;;
*)
usage
;;
esac
exit 0
|