Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:master commit in: scripts/
Date: Thu, 17 Nov 2011 18:29:02
Message-Id: 260b61e9d87510b869f2b7b8fefd281ea695f88e.WilliamH@gentoo
1 commit: 260b61e9d87510b869f2b7b8fefd281ea695f88e
2 Author: Alessio Ababilov <ilovedevlinux <AT> gmail <DOT> com>
3 AuthorDate: Thu Nov 17 15:48:38 2011 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Thu Nov 17 17:55:44 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=260b61e9
7
8 on_ac_power: Fix AC adapter presence recognition
9
10 On several machines, a file corresponding to AC adapter can be named
11 ADP1. The on_ac_power script checked for AC*, which does not match
12 ADP1, so the script always considered the adapter to be off.
13
14 X-Gentoo-Bug: 380933
15 X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=380933
16
17 ---
18 scripts/on_ac_power | 8 ++++----
19 1 files changed, 4 insertions(+), 4 deletions(-)
20
21 diff --git a/scripts/on_ac_power b/scripts/on_ac_power
22 index 3655b83..5dd516f 100755
23 --- a/scripts/on_ac_power
24 +++ b/scripts/on_ac_power
25 @@ -3,14 +3,14 @@
26 # Copyright (c) 2007-2009 Roy Marples <roy@×××××××.name>
27
28 # Exit 0 if on AC power, 1 if not and 255 if we don't know how to work it out
29 -if [ -f /proc/acpi/ac_adapter/AC*/state ]; then
30 - cat /proc/acpi/ac_adapter/AC*/state | while read line; do
31 +if [ -f /proc/acpi/ac_adapter/*/state ]; then
32 + cat /proc/acpi/ac_adapter/*/state | while read line; do
33 case "$line" in
34 "state:"*"off-line") exit 128;;
35 esac
36 done
37 -elif [ -f /sys/class/power_supply/AC*/online ]; then
38 - cat /sys/class/power_supply/AC*/online | while read line; do
39 +elif [ -f /sys/class/power_supply/*/online ]; then
40 + cat /sys/class/power_supply/*/online | while read line; do
41 [ "${line}" = 0 ] && exit 128
42 done
43 elif [ -f /proc/pmu/info ]; then