From e8d0b58a9df080f021d04b4c2d358003974092f3 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Tue, 23 Feb 2010 13:57:05 +0000 Subject: on_ac_power: support UPower (new name for DeviceKit-power) DeviceKit-power got renamed to UPower and its D-Bus interface changed accordingly. Try UPower first in on_ac_power. If it fails, try DeviceKit-power. It if fails too, try hal. Also update documentation. Signed-off-by: Michael Biebl --- diff --git a/man/pm-action.xml b/man/pm-action.xml index ccb4153..6e9f639 100644 --- a/man/pm-action.xml +++ b/man/pm-action.xml @@ -104,7 +104,7 @@ For some options external programs are needed. - These commands will usually be called by DeviceKit-power + These commands will usually be called by UPower or hald when triggered to do so by a program in a desktop session such as gnome-power-manager. Calling them from the command line is also possible, but it is not diff --git a/man/pm-is-supported.xml b/man/pm-is-supported.xml index 88bb9fd..d07c87d 100644 --- a/man/pm-is-supported.xml +++ b/man/pm-is-supported.xml @@ -89,7 +89,7 @@ The intended purpose of &dhpackage; is to find out which power management modes are supported by the - system. hald(8) will call it to do just that. (Note that DeviceKit-power + system. hald(8) will call it to do just that. (Note that UPower does not use this.) @@ -161,10 +161,6 @@ - DeviceKit-power - 7 - , - hald 8 , @@ -175,6 +171,10 @@ s2both 8 + , + + UPower + 7 diff --git a/src/on_ac_power b/src/on_ac_power index fdbcb36..1f9c59e 100755 --- a/src/on_ac_power +++ b/src/on_ac_power @@ -30,7 +30,17 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# prefer DeviceKit-power if available +# prefer UPower if available +if s="$(dbus-send --system --print-reply \ + --dest=org.freedesktop.UPower \ + /org/freedesktop/UPower \ + org.freedesktop.DBus.Properties.Get \ + string:org.freedesktop.UPower string:OnBattery)"; then + echo "$s" | grep -q 'boolean false' + exit $? +fi + +# try its old name 'DeviceKit-power' too if s="$(dbus-send --system --print-reply \ --dest=org.freedesktop.DeviceKit.Power \ /org/freedesktop/DeviceKit/Power \ -- cgit v0.8.3-6-g21f6