diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/.bin/bat | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/bin/.bin/bat b/bin/.bin/bat index 38f4272..72e30a2 100755 --- a/bin/.bin/bat +++ b/bin/.bin/bat | |||
@@ -1,34 +1,15 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | pane() { | 3 | while true |
4 | do | ||
4 | battery_level=$(cat /sys/class/power_supply/BAT*/capacity) | 5 | battery_level=$(cat /sys/class/power_supply/BAT*/capacity) |
5 | state=$(cat /sys/class/power_supply/BAT0/status) | 6 | state=$(cat /sys/class/power_supply/BAT*/status) |
6 | if [ $state == "Charging" ]; then | 7 | if [ $battery_level -ge 90 ] && [ $state == "Charging" ]; then |
7 | echo -e +$battery_level% | 8 | notify-send 'Pull the plug!' $battery_level% |
8 | else | 9 | elif [ $battery_level -le 30 -a $battery_level -ge 20 ] && [ $state == "Discharging" ]; then |
9 | echo -e $battery_level% | 10 | notify-send 'Plug me!' $battery_level% |
11 | elif [ $battery_level -le 20 ] && [ $state == "Discharging" ]; then | ||
12 | notify-send -u critical 'Plug me NOW!' $battery_level% | ||
10 | fi | 13 | fi |
11 | } | 14 | sleep 300 |
12 | 15 | done | |
13 | notifs() { | ||
14 | while true | ||
15 | do | ||
16 | battery_level=$(cat /sys/class/power_supply/BAT*/capacity) | ||
17 | state=$(cat /sys/class/power_supply/BAT*/status) | ||
18 | if [ $battery_level -ge 90 ] && [ $state == "Charging" ]; then | ||
19 | notify-send 'Pull the plug!' $battery_level% | ||
20 | elif [ $battery_level -le 30 -a $battery_level -ge 20 ] && [ $state == "Discharging" ]; then | ||
21 | notify-send 'Plug me!' $battery_level% | ||
22 | elif [ $battery_level -le 20 ] && [ $state == "Discharging" ]; then | ||
23 | notify-send -u critical 'Plug me NOW!' $battery_level% | ||
24 | fi | ||
25 | sleep 300 | ||
26 | done | ||
27 | } | ||
28 | |||
29 | case "$1" in | ||
30 | n) | ||
31 | notifs;; | ||
32 | *) | ||
33 | pane;; | ||
34 | esac | ||