diff options
Diffstat (limited to 'etc/functions/check_nobat')
-rw-r--r-- | etc/functions/check_nobat | 10 |
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 |