summaryrefslogtreecommitdiff
path: root/bin/.bin/bat_check
diff options
context:
space:
mode:
authorShubham Saini <pryr@pryr.xyz>2020-12-01 20:21:04 +0000
committerShubham Saini <pryr@pryr.xyz>2020-12-01 20:21:04 +0000
commit1ff834e2b06761b083df9959d6c3d6bd2a94d2de (patch)
treeabb8ff13bab1c6b5a0c0b17f2d29c058358d2135 /bin/.bin/bat_check
parent90e96958f919df1f914381e93a97d77506fdcf03 (diff)
mah thinkpad
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