-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbattery-warner
executable file
·42 lines (41 loc) · 1.03 KB
/
battery-warner
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
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
source ~/Repositories/scripts/essential-functions
while true
do
sleep 3s
[[ -z "$adap" ]] && adap="$(acpi -a | awk '{print $NF}')"
newadap="$(acpi -a | awk '{print $NF}')"
[[ ! "$adap" = "$newadap" ]] && {
case "$adap$newadap" in
"on-lineoff-line") sfx adapter-removed ;;
"off-lineon-line") sfx adapter-connect ;;
esac
}
adap="$newadap"
[[ "$adap" = "on-line" ]] && continue
battery-low-detect
[[ "$batterylow" -eq 1 ]] && {
source ~/Repositories/dotfiles/zsh/variables
[[ "$battery_warning_on" -eq 0 ]] && continue
killall dunst
remaining="$(acpi -b | sed -n 2p | awk -F ', ' '{print $NF}')"
notify-send -u critical -t 4000 "BATTERY WARNING" "${batterypercent}%\n$remaining"
quodlibet --pause
[[ "$batterypercent" -eq 25 ]] && {
sfx dont-sink
continue
}
[[ "$batterypercent" -gt 19 ]] && {
sfx terrain
continue
}
[[ "$batterypercent" -gt 9 ]] && {
sfx too-low
continue
}
[[ "$batterypercent" -ge 0 ]] && {
sfx pull-up
continue
}
}
done