summaryrefslogtreecommitdiff
path: root/bin/.bin/bat
diff options
context:
space:
mode:
authorShubham Saini <pryr@pryr.xyz>2021-05-22 19:18:51 +0000
committerShubham Saini <pryr@pryr.xyz>2021-05-22 19:18:51 +0000
commit72ccd83ccc66d942b855fe8379bc3f0d24384b76 (patch)
tree515997e25fb736ee1e3481dc941c1b540c03624b /bin/.bin/bat
parentbde9d8e1c9a6e2213fc7d40298d43a14f2e99359 (diff)
improved scripts
Diffstat (limited to 'bin/.bin/bat')
-rwxr-xr-xbin/.bin/bat34
1 files changed, 28 insertions, 6 deletions
diff --git a/bin/.bin/bat b/bin/.bin/bat
index 473c7e2..38f4272 100755
--- a/bin/.bin/bat
+++ b/bin/.bin/bat
@@ -1,12 +1,34 @@
1#!/bin/bash 1#!/bin/sh
2while true 2
3do 3pane() {
4 battery_level=$(cat /sys/class/power_supply/BAT0/capacity) 4 battery_level=$(cat /sys/class/power_supply/BAT*/capacity)
5 state=$(cat /sys/class/power_supply/BAT0/status) 5 state=$(cat /sys/class/power_supply/BAT0/status)
6 if [ $state == "Charging" ]; then 6 if [ $state == "Charging" ]; then
7 echo -e +$battery_level% 7 echo -e +$battery_level%
8 else 8 else
9 echo -e $battery_level% 9 echo -e $battery_level%
10 fi 10 fi
11 sleep 3 11}
12done 12
13notifs() {
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
29case "$1" in
30 n)
31 notifs;;
32 *)
33 pane;;
34esac