diff --git a/acpid.init b/acpid.init index 61e7c51..fd0a375 100755 --- a/acpid.init +++ b/acpid.init @@ -27,12 +27,17 @@ RETVAL=0 # See how we were called. # -start() { +check() { # Check that we're a privileged user [ `id -u` = 0 ] || exit 4 # Check if acpid is executable test -x /usr/sbin/acpid || exit 5 +} + +start() { + + check # Check for kernel support [ -f /proc/acpi/event ] || exit 1 @@ -49,6 +54,9 @@ start() { } stop() { + + check + echo -n $"Stopping acpi daemon: " killproc /usr/sbin/acpid RETVAL=$? @@ -64,6 +72,9 @@ restart() { } reload() { + + check + trap "" SIGHUP action $"Reloading acpi daemon:" killall -HUP acpid RETVAL=$? diff --git a/acpid.power.sh b/acpid.power.sh new file mode 100644 index 0000000..0f75970 --- /dev/null +++ b/acpid.power.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +PATH=/sbin:/bin:/usr/bin + +# Get the ID of the first active X11 session: +uid_session=$( +ck-list-sessions | \ +awk ' +/^Session[0-9]+:$/ { uid = active = x11 = "" ; next } +{ gsub(/'\''/, "", $3) } +$1 == "unix-user" { uid = $3 } +$1 == "active" { active = $3 } +$1 == "x11-display" { x11 = $3 } +active == "TRUE" && x11 != "" { + print uid + exit +}') + +# Check that there is a power manager, otherwise shut down. +[ "$uid_session" ] && +ps axo uid,cmd | \ +awk ' + $1 == '$uid_session' && + ($2 ~ /gnome-power-manager/ || $2 ~ /kpowersave/) \ + { found = 1; exit } + END { exit !found } +' || + shutdown -h now + diff --git a/acpid.spec b/acpid.spec index c9a4907..519163b 100644 --- a/acpid.spec +++ b/acpid.spec @@ -1,7 +1,7 @@ Summary: ACPI Event Daemon Name: acpid Version: 1.0.6 -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv2+ Group: System Environment/Daemons Source: http://prdownloads.sourceforge.net/acpid/acpid-%{version}.tar.gz @@ -87,6 +87,11 @@ if [ "$1" -ge "1" ]; then fi %changelog +* Tue Nov 11 2008 Zdenek Prikryl - 1.0.6-9 +- power.sh works with ConsoleKit >= 0.3.0 (#470752) +- Fixed conditions in power.sh, which look for power-managers (#470752) +- Added check to init script + * Mon Jul 14 2008 Tom "spot" Callaway - 1.0.6-8 - fix license tag diff --git a/sources b/sources index c384bf1..966c470 100644 --- a/sources +++ b/sources @@ -1,2 +1 @@ 5c9b705700df51d232be223b6ab6414d acpid-1.0.6.tar.gz -581b7998a78b140ca58c428338c734ed acpid.power.sh