-
Notifications
You must be signed in to change notification settings - Fork 0
/
batteryWarning
executable file
·29 lines (22 loc) · 1.27 KB
/
batteryWarning
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
#!/bin/bash
#batteryWarning
export XDG_RUNTIME_DIR=/run/user/1000
battery_stat="$(acpi --battery)"
battery_greped_status="$(echo $battery_stat | grep -Pio 'remaining|charged')"
battery_percentage_v="$(echo $battery_stat | grep -Po '(\d+%)' | grep -Po '\d+')"
if [ "$battery_greped_status" == "remaining" ]; then
runtime="$(echo $battery_stat | grep -Po '[0-9]+:[0-9]+:[0-9]+')"
if [ "$battery_percentage_v" -lt 5 ]; then
dunstify -a system -i "/usr/share/icons/Papirus/48x48/status/notification-power.svg" -t 0 -r 9990 -u critical "Battery Low" "Your system will sleep soon unless plugged into a power outlet."
aplay /home/aayush/downloads/charge_your_battery.wav
fi
if [ "$battery_percentage_v" -lt 30 ]; then
dunstify -a system -i "/usr/share/icons/Papirus/48x48/status/notification-power.svg" -t 0 -r 9990 -u critical "Battery Low" "Your system will sleep soon unless plugged into a power outlet."
fi
# Remind to disconnect charger if battery >=98%
elif [ "$battery_greped_status" == "charged" ]; then
if [ "$battery_percentage_v" -ge 90 ]; then
dunstify -a system -i "/usr/share/icons/Papirus/48x48/status/battery-full-charged.svg" -t 9000 -r 9990 -u normal "Battery ${battery_percentage_v}%" "Disconnect Charger please."
aplay /home/aayush/Downloads/battery_95.wav
fi
fi