Modified: bin/battery-daemon
This commit is contained in:
parent
4d9c3d89f4
commit
226bcbf900
|
@ -19,14 +19,14 @@ while true; do
|
||||||
path_to_battery=$(upower -e | grep BAT)
|
path_to_battery=$(upower -e | grep BAT)
|
||||||
battery_level=$(upower -i "$path_to_battery" | grep -E "percentage" | sed 's/[^0-9]//g')
|
battery_level=$(upower -i "$path_to_battery" | grep -E "percentage" | sed 's/[^0-9]//g')
|
||||||
discharging=$(upower -i "$path_to_battery" | grep -E "state" | grep -c "discharging")
|
discharging=$(upower -i "$path_to_battery" | grep -E "state" | grep -c "discharging")
|
||||||
time_to_empty=$(upower -i "$path_to_battery" | grep -E "time to empty" | sed 's/[^0-9,.]//g')
|
time_to_empty=$(upower -i "$path_to_battery" | grep -E "time to empty" | sed 's/^[[:space:]]*time to empty:[[:space:]]*//')
|
||||||
|
|
||||||
# check if battery is low and discharging
|
# check if battery is low and discharging
|
||||||
if [ "$battery_level" -lt "$warning_level" ] && [ "$discharging" -eq 1 ] && [ "$is_first_start" = false ];
|
if [ "$battery_level" -lt "$warning_level" ] && [ "$discharging" -eq 1 ] && [ "$is_first_start" = false ];
|
||||||
then
|
then
|
||||||
dunstify -a "Battery" \
|
dunstify -a "Battery" \
|
||||||
"Low battery: ${battery_level}%" \
|
"Low battery: ${battery_level}%" \
|
||||||
"Battery is low ($time_to_empty hours left)" \
|
"Battery is low ($time_to_empty left)" \
|
||||||
-r 100 \
|
-r 100 \
|
||||||
-i "$notify_icons/battery-low.png"
|
-i "$notify_icons/battery-low.png"
|
||||||
mpv "/home/q/.config/alarm/low-battery-sound.mp3" > /dev/null 2>&1
|
mpv "/home/q/.config/alarm/low-battery-sound.mp3" > /dev/null 2>&1
|
||||||
|
|
Loading…
Reference in New Issue