File apcupsd-powersave.patch of Package apcupsd

Index: examples/safe.apccontrol.in
===================================================================
--- examples/safe.apccontrol.in.orig
+++ examples/safe.apccontrol.in
@@ -15,96 +15,128 @@ SCRIPTDIR=@sysconfdir@
 #
 case "$1" in
         killpower)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: ${APCUPSD} --killpower would have been."
                 wall <<EOF
 apccontrol: ${APCUPSD} --killpower would have been.
 
 EOF
         ;;
         commfailure)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: Communications with UPS lost."
                 wall <<EOF
 apccontrol: Communications with UPS lost.
 
 EOF
         ;;
         commok)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: Communciations with UPS restored."
                 wall <<EOF
 apccontrol: Communciations with UPS restored.
 
 EOF
         ;;
         powerout)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: Warning power loss detected."
                 wall <<EOF
 apccontrol: Warning power loss detected.
 
 EOF
         ;;
         onbattery)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: Power failure. Running on UPS batteries."
                 wall <<EOF
 apccontrol: Power failure. Running on UPS batteries.
 
 EOF
         ;;
         offbattery)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: Off battery. Mains returned."
                 wall <<EOF
 apccontrol: Off battery. Mains returned.
 
 EOF
         ;;
         failing)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: UPS battery power exhaused. Doing shutdown."
                 wall <<EOF
 apccontrol: UPS battery power exhaused. Doing shutdown.
 
 EOF
         ;;
         timeout)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: UPS battery runtime limit exceeded. Doing shutdown."
                 wall <<EOF
 apccontrol: UPS battery runtime limit exceeded. Doing shutdown.
 
 EOF
         ;;
         loadlimit)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: UPS battery discharge limit reached. Doing shutdown."
                 wall <<EOF
 apccontrol: UPS battery discharge limit reached. Doing shutdown.
 
 EOF
         ;;
         runlimit)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: UPS battery runtime percent reached. Doing shutdown."
                 wall <<EOF
 apccontrol: UPS battery runtime percent reached. Doing shutdown.
 
 EOF
         ;;
         doreboot)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: ${SHUTDOWN} for reboot would have been called."
                 wall <EOF
 apccontrol: ${SHUTDOWN} for reboot would have been called.
 
 EOF
         ;;
         doshutdown)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: ${SHUTDOWN} for halt would have been called."
                 wall <<EOF
 apccontrol: ${SHUTDOWN} for halt would have been called.
 
 EOF
         ;;
         mainsback)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: Power has returned..."
                 wall <<EOF
 apccontrol: Power has returned...
 
 EOF
         ;;
         annoyme)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: Power problems please logoff."
                 wall <<EOF
 apccontrol: Power problems please logoff.
 
 EOF
         ;;
         emergency)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: ${SHUTDOWN} for emergency halt would have been called."
                 wall <<EOF
 apccontrol: ${SHUTDOWN} for emergency halt would have been called.
 
 EOF
         ;;
         changeme)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: Emergency! UPS batteries have failed."
                 wall <<EOF
 apccontrol: Emergency! UPS batteries have failed.
 
@@ -112,18 +144,24 @@ Change them NOW !
 EOF
         ;;
         remotedown)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: ${SHUTDOWN} for remote halt would have been called."
                 wall <<EOF
 apccontrol: ${SHUTDOWN} for remote halt would have been called.
 
 EOF
         ;;
         startselftest)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: start self test would have been called."
                 wall <<EOF
 apccontrol: start self test would have been called.
 
 EOF
         ;;
         endselftest)
+                /usr/lib/powersave/powersave-notify \
+"apccontrol: end self test would have been called."
                 wall <<EOF
 apccontrol: end self test would have been called.
 
Index: platforms/apccontrol.in
===================================================================
--- platforms/apccontrol.in.orig
+++ platforms/apccontrol.in
@@ -25,6 +25,7 @@ SHUTDOWN=@SHUTDOWN@
 SCRIPTSHELL=@SCRIPTSHELL@
 SCRIPTDIR=@sysconfdir@
 WALL=wall
+NOTIFY=/usr/lib/powersave/powersave-notify
 
 #
 # Concatenate all output from this script to the events file
@@ -57,18 +58,23 @@ then
     fi
 fi
 
+function notify() {
+    ${NOTIFY} "$1"
+    echo "$1" | ${WALL}
+}
+
 case "$1" in
     killpower)
-	echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}" | ${WALL}
+	notify "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}"
 	sleep 10
 	${APCUPSD} --killpower
-	echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | ${WALL}
+	notify "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}"
     ;;
     commfailure)
-	echo "Warning communications lost with UPS ${2}" | ${WALL}
+	notify "Warning communications lost with UPS ${2}"
     ;;
     commok)
-	echo "Communications restored with UPS ${2}" | ${WALL}
+	notify "Communications restored with UPS ${2}"
     ;;
 #
 # powerout, onbattery, offbattery, mainsback events occur
@@ -77,53 +83,53 @@ case "$1" in
     powerout)
     ;;
     onbattery)
-	echo "Power failure on UPS ${2}. Running on batteries." | ${WALL}
+	notify "Power failure on UPS ${2}. Running on batteries."
     ;;
     offbattery)
-	echo "Power has returned on UPS ${2}..." | ${WALL}
+	notify "Power has returned on UPS ${2}..."
     ;;
     mainsback)
 	if [ -f @PWRFAILDIR@/powerfail ] ; then
-	   printf "Continuing with shutdown."  | ${WALL}
+	   notify "Continuing with shutdown."
 	fi
     ;;
     failing)
-	echo "Battery power exhaused on UPS ${2}. Doing shutdown." | ${WALL}
+	notify "Battery power exhaused on UPS ${2}. Doing shutdown."
     ;;
     timeout)
-	echo "Battery time limit exceeded on UPS ${2}. Doing shutdown." | ${WALL}
+	notify "Battery time limit exceeded on UPS ${2}. Doing shutdown."
     ;;
     loadlimit)
-	echo "Remaining battery charge below limit on UPS ${2}. Doing shutdown." | ${WALL}
+	notify "Remaining battery charge below limit on UPS ${2}. Doing shutdown."
     ;;
     runlimit)
-	echo "Remaining battery runtime below limit on UPS ${2}. Doing shutdown." | ${WALL}
+	notify "Remaining battery runtime below limit on UPS ${2}. Doing shutdown."
     ;;
     doreboot)
-	echo "UPS ${2} initiating Reboot Sequence" | ${WALL}
+	notify "UPS ${2} initiating Reboot Sequence"
 	${SHUTDOWN} -r now "apcupsd UPS ${2} initiated reboot"
     ;;
     doshutdown)
 	. /etc/sysconfig/apcupsd
 	if test "$APCUPSD_POWERFAIL_BEHAVIOR" = "hibernate" ; then
-		echo "UPS ${2} initiated hibernation" | ${WALL}
+		notify "UPS ${2} initiated hibernation"
 		$HIBERNATE
 	else
-		echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
+		notify "UPS ${2} initiated Shutdown Sequence"
 		${SHUTDOWN} -h now "apcupsd UPS ${2} initiated shutdown"
 	fi
     ;;
     annoyme)
-	echo "Power problems with UPS ${2}. Please logoff." | ${WALL}
+	notify "Power problems with UPS ${2}. Please logoff."
     ;;
     emergency)
-	echo "Emergency Shutdown. Possible battery failure on UPS ${2}." | ${WALL}
+	notify "Emergency Shutdown. Possible battery failure on UPS ${2}."
     ;;
     changeme)
-	echo "Emergency! Batteries have failed on UPS ${2}. Change them NOW" | ${WALL}
+	notify "Emergency! Batteries have failed on UPS ${2}. Change them NOW"
     ;;
     remotedown)
-	echo "Remote Shutdown. Beginning Shutdown Sequence." | ${WALL}
+	notify "Remote Shutdown. Beginning Shutdown Sequence."
     ;;
     startselftest)
     ;;
openSUSE Build Service is sponsored by