mirror of
https://github.com/GRFreire/scripts.git
synced 2026-01-09 04:49:38 +00:00
18 lines
574 B
Bash
Executable File
18 lines
574 B
Bash
Executable File
#!/bin/sh
|
|
|
|
DEVICE="/org/freedesktop/UPower/devices/battery_BAT0"
|
|
|
|
time="$(upower -i $DEVICE | grep time | cut -d':' -f2 | tr -s ' ' | cut -c2-)"
|
|
perc="$(upower -i $DEVICE | grep percentage | awk '{print $2}' | tr -d '%')"
|
|
stat="$(upower -i $DEVICE | grep state | awk '{print $2}')"
|
|
|
|
if [ "$perc" -le "20" ]; then
|
|
urgency="normal"
|
|
if [ "$perc" -le "10" ]; then
|
|
urgency="critical"
|
|
fi
|
|
notify-send -u "$urgency" --icon="battery" "Battery is low ($perc%)" "Time remaining is $time."
|
|
mpv /usr/share/sounds/freedesktop/stereo/dialog-information.oga
|
|
fi
|
|
|