summaryrefslogtreecommitdiff
path: root/bin/.bin/bat_check
diff options
context:
space:
mode:
Diffstat (limited to 'bin/.bin/bat_check')
-rwxr-xr-xbin/.bin/bat_check14
1 files changed, 14 insertions, 0 deletions
diff --git a/bin/.bin/bat_check b/bin/.bin/bat_check
new file mode 100755
index 0000000..547b976
--- /dev/null
+++ b/bin/.bin/bat_check
@@ -0,0 +1,14 @@
1#!/bin/bash
2while true
3do
4 battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
5 state=$(cat /sys/class/power_supply/BAT0/status)
6 if [ $battery_level -ge 90 ] && [ $state == "Charging" ]; then
7 notify-send 'Pull the plug!' $battery_level%
8 elif [ $battery_level -le 30 -a $battery_level -ge 20 ] && [ $state == "Discharging" ]; then
9 notify-send 'Plug me!' $battery_level%
10 elif [ $battery_level -le 20 ] && [ $state == "Discharging" ]; then
11 notify-send -u critical 'Plug me NOW!' $battery_level%
12 fi
13 sleep 300 # 300 seconds or 5 minutes
14done