summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--pm/power.d/disable_wol2
-rw-r--r--pm/power.d/sata_alpm2
-rwxr-xr-xsrc/on_ac_power43
4 files changed, 14 insertions, 35 deletions
diff --git a/configure.ac b/configure.ac
index 336c3b5..a5a991b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
AC_PREREQ(2.52)
-AC_INIT(pm-utils, 1.4.0-rc2)
+AC_INIT(pm-utils, 1.4.0)
AC_CONFIG_SRCDIR(src)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AM_CONFIG_HEADER(config.h)
diff --git a/pm/power.d/disable_wol b/pm/power.d/disable_wol
index 027eec5..ab4dda9 100644
--- a/pm/power.d/disable_wol
+++ b/pm/power.d/disable_wol
@@ -6,7 +6,7 @@ command_exists ethtool || exit $NA
set_wol_status() {
for d in "/sys/class/net/"*; do
- [ -f "$d/wireless" ] && continue
+ [ -e "$d/wireless" ] && continue
[ -h "$d/device/driver" ] || continue
printf "Setting Wake On Lan for %s to %s..." "${d##*/}" "$1"
case $1 in
diff --git a/pm/power.d/sata_alpm b/pm/power.d/sata_alpm
index dbe4117..5ede307 100644
--- a/pm/power.d/sata_alpm
+++ b/pm/power.d/sata_alpm
@@ -26,7 +26,7 @@ set_sata_alpm() {
kv="$(uname -r)"
[ "$kv" ] || exit $NA #for paranoia's sake
[ "${kv%-*}" \< "2.6.33" ] && exit $NA # avoid fs corruption
- for f in /sys/class/scsi_host/host*/link_power_management_policy; do
+ for f in /sys/class/scsi_host/host*; do
[ -w "$f/link_power_management_policy" ] || continue
printf "Setting SATA APLM on %s to %s..." "${f##*/}" "$1"
echo "$1" > "$f/link_power_management_policy" && echo Done. || \
diff --git a/src/on_ac_power b/src/on_ac_power
index 1f9c59e..b0aa105 100755
--- a/src/on_ac_power
+++ b/src/on_ac_power
@@ -30,38 +30,17 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# 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
+# If we do not have any power supplies, assume we are on AC
+ret=0
-# try its old name 'DeviceKit-power' too
-if s="$(dbus-send --system --print-reply \
- --dest=org.freedesktop.DeviceKit.Power \
- /org/freedesktop/DeviceKit/Power \
- org.freedesktop.DBus.Properties.Get \
- string:org.freedesktop.DeviceKit.Power string:OnBattery)"; then
- echo "$s" | grep -q 'boolean false'
- exit $?
-fi
-
-# Check for AC/DC/etc adapters
-ac_adapters="$(hal-find-by-capability --capability ac_adapter)"
-
-# If there are no AC adapters, it is most likely a desktop.
-# Assume online, since we have no data.
-[ -z "$ac_adapters" ] && exit 0
-
-# If any of them are online, then we're done.
-for device in $ac_adapters ; do
- present="$(hal-get-property --udi "$device" --key ac_adapter.present)"
- [ "$present" = "true" ] && exit 0
+# Iterate through power supplies sysfs knows about.
+for ps in /sys/class/power_supply/*; do
+ [ -r "$ps/online" ] || continue
+ # OK, we know we have an AC adaptor.
+ # Our default return changes to failed.
+ ret=1
+ read -r ps_status < "$ps/online"
+ [ 1 -eq "$ps_status" ] && exit 0
done
-# If there are adapters, but none are online, we're not on AC.
-exit 1
+exit "$ret"