-
Notifications
You must be signed in to change notification settings - Fork 0
/
sb-battery
executable file
·32 lines (27 loc) · 935 Bytes
/
sb-battery
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
# Read battery charge level
#charge="$(acpi | awk '{print $4}' | tr -d "%" | tr -d ",")"
charge="$(cat /sys/class/power_supply/BAT[0-9]/capacity)"
# Read battery status
#stat="$(acpi | awk '{print $3}' | tr -d ",")"
stat="$(cat /sys/class/power_supply/BAT[0-9]/capacity_level)"
case $BUTTON in
# Left-click opens a terminal instance with advanced battery statistics
1) setsid -f "$TERMINAL" -e watch $charge ;;
# Right-click creates a notification about battery status and chrarge level
3) notify-send "Battery" " $stat $charge%" ;;
esac
# Display sound icon depending on volume
if [ "$charge" -gt "75" ]; then
icon=" "
elif [ "$charge" -gt "50" ]; then
icon=" "
elif [ "$charge" -gt "25" ]; then
icon=" "
elif [ "$charge" -gt "0" ]; then
icon=" "
else
echo " 0%" && exit
fi
# Display icon, battery status and charge percentage
echo "$icon $stat $charge%"