diff options
author | Brian Harring <ferringb@chromium.org> | 2012-05-25 02:21:06 -0700 |
---|---|---|
committer | Brian Harring <ferringb@chromium.org> | 2012-05-25 02:25:59 -0700 |
commit | 6a927c5d1990a9391242baa00c5ac71490c50c28 (patch) | |
tree | 78e93bbfe8efa4cd0f10edc69dbc01d559407d89 /hooks | |
parent | eca119e5d6f0aa61cad6be1421aa523482e9cde7 (diff) | |
download | git-repo-6a927c5d1990a9391242baa00c5ac71490c50c28.tar.gz |
hooks/pre-auto-gc: look in sysfs to see if a battery is known.
Barring any kernel bugs, if this directory exists and there is
a symlink in there (which will point to the battery object),
that means there is a battery known to the kernel.
No symlink should mean no battery as far as the kernel is concerned.
Change-Id: Ib12819a5bbb816f0ae5ca080e5812a2db08441e9
Diffstat (limited to 'hooks')
-rwxr-xr-x | hooks/pre-auto-gc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/hooks/pre-auto-gc b/hooks/pre-auto-gc index 110e3194..360e5e1f 100755 --- a/hooks/pre-auto-gc +++ b/hooks/pre-auto-gc | |||
@@ -38,6 +38,11 @@ elif test -x /usr/bin/pmset && /usr/bin/pmset -g batt | | |||
38 | grep -q "Currently drawing from 'AC Power'" | 38 | grep -q "Currently drawing from 'AC Power'" |
39 | then | 39 | then |
40 | exit 0 | 40 | exit 0 |
41 | elif test -d /sys/bus/acpi/drivers/battery && test 0 = \ | ||
42 | "$(find /sys/bus/acpi/drivers/battery/ -type l | wc -l)"; | ||
43 | then | ||
44 | # No battery exists. | ||
45 | exit 0 | ||
41 | fi | 46 | fi |
42 | 47 | ||
43 | echo "Auto packing deferred; not on AC" | 48 | echo "Auto packing deferred; not on AC" |