summaryrefslogtreecommitdiff
path: root/checkbattery
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2018-06-13 21:36:56 -0700
committerBen Sima <ben@bsima.me>2018-06-13 21:36:56 -0700
commit77c9a177b2b595d4ce25095b58e2388fe33cc97a (patch)
tree0853d5c92d67538760005b9c4635a90115bd7ba4 /checkbattery
init
Diffstat (limited to 'checkbattery')
-rwxr-xr-xcheckbattery15
1 files changed, 15 insertions, 0 deletions
diff --git a/checkbattery b/checkbattery
new file mode 100755
index 0000000..5b4cfe6
--- /dev/null
+++ b/checkbattery
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+export DISPLAY=:0
+
+BATT=`acpi -b | grep -P -o '[0-9]+(?=%)'`
+TIME=`acpi -b | grep -P -o '[0-9]{2}:[0-9]{2}:[0-9]{2}'`
+
+if (( $BATT < 10 ))
+then
+ notify-send -u critical "LOW BATTERY!" "\
+Battery Charge: ${BATT}%
+Time Remaining: ${TIME}"
+fi
+
+exit 0