diff options
author | Shubham Saini <shubham6405@gmail.com> | 2020-06-03 10:56:37 +0000 |
---|---|---|
committer | Shubham Saini <shubham6405@gmail.com> | 2020-06-03 10:56:37 +0000 |
commit | 9a334a3d5ffda8aa26302e729fe504dc6400fc1e (patch) | |
tree | 6a9dbd97f4f0b0f08aaa9ca9c602544f82d1bd8e | |
parent | 93767e79ffd885855b18edbaffaaa27f475cac13 (diff) |
changed bat_check
-rwxr-xr-x | bin/.local/bin/bat_check.sh | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/.local/bin/bat_check.sh b/bin/.local/bin/bat_check.sh index b54ce7b..abfb06f 100755 --- a/bin/.local/bin/bat_check.sh +++ b/bin/.local/bin/bat_check.sh | |||
@@ -2,12 +2,13 @@ | |||
2 | while true | 2 | while true |
3 | do | 3 | do |
4 | battery_level=$(cat /sys/class/power_supply/BAT0/capacity) | 4 | battery_level=$(cat /sys/class/power_supply/BAT0/capacity) |
5 | if [ $battery_level -ge 95 ]; then | 5 | state=$(cat /sys/class/power_supply/BAT0/status) |
6 | if [ $battery_level -ge 95 ] && [ $state == "Discharging" ]; then | ||
6 | notify-send 'Pull the plug!' $battery_level% | 7 | notify-send 'Pull the plug!' $battery_level% |
7 | elif [ $battery_level -le 30 -a $battery_level -ge 20 ]; then | 8 | elif [ $battery_level -le 30 -a $battery_level -ge 20 ] && [ $state == "Discharging" ]; then |
8 | notify-send 'Plug me!' $battery_level% | 9 | notify-send 'Plug me!' $battery_level% |
9 | elif [ $battery_level -le 20 ]; then | 10 | elif [ $battery_level -le 20 ] && [ $state == "Discharging" ]; then |
10 | notify-send -u critical 'Plug me NOW!' $battery_level% | 11 | notify-send -u critical 'Plug me NOW!' $battery_level% |
11 | fi | 12 | fi |
12 | sleep 300 # 300 seconds or 5 minutes | 13 | sleep 2 # 300 seconds or 5 minutes |
13 | done | 14 | done |