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
|
Description: Handle on_ac_power 255 return code
As we are using the on_ac_power utility from powermgmt-base, which returns
255 when it can't determine the AC power state, assume we have a desktop
system in such a case. This behaviour is compatible with the pm-utils upstream
implementation of on_ac_power.
Debian-Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572060
Author: Michael Biebl <biebl@debian.org>
Index: pm-utils/src/pm-powersave.in
===================================================================
--- pm-utils.orig/src/pm-powersave.in 2010-06-18 08:14:29.000000000 +0200
+++ pm-utils/src/pm-powersave.in 2010-06-18 16:10:05.608067653 +0200
@@ -65,10 +65,19 @@
init_logfile "${PM_LOGFILE}"
}
+_on_ac_power() {
+ on_ac_power
+ case $? in
+ # If on_ac_power can't determine AC power state (255), assume it's a desktop.
+ 0|255) return 0 ;;
+ 1) return 1 ;;
+ esac
+}
+
case $1 in
true|battery) lock_and_load && run_hooks power true;;
false|ac) lock_and_load && run_hooks power false;;
--help) help && run_hooks power help;;
- '') lock_and_load; on_ac_power && run_hooks power false || run_hooks power true;;
+ '') lock_and_load; _on_ac_power && run_hooks power false || run_hooks power true;;
*) help && exit 1;;
esac
|