summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-03-07 12:04:30 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-03-07 12:04:30 +0100
commit3b2155bcb52db95c3c00fac1674119445a1a1d94 (patch)
tree6605af7228581940d7e9e7939e2a2d5b0935bafa /etc
parent3e93180e386de3f232b2139f620c3dd43a6516f4 (diff)
Added check_nobat function to check if we're running on battery power
Diffstat (limited to 'etc')
-rw-r--r--etc/functions/check_nobat10
1 files changed, 10 insertions, 0 deletions
diff --git a/etc/functions/check_nobat b/etc/functions/check_nobat
new file mode 100644
index 0000000..0f5dca3
--- /dev/null
+++ b/etc/functions/check_nobat
@@ -0,0 +1,10 @@
+## vim:ft=zsh
+## check_nobat - returns true if machine is _not_ running on battery
+typeset state
+typeset -i ret=0
+
+for state in /proc/acpi/battery/*/state(N); {
+ fgrep -i 'discharging' $state &> /dev/null && ret=1
+}
+
+return $ret