extra-scripts/battery-warn

22 lines
701 B
Plaintext
Raw Normal View History

2021-11-28 18:29:51 +01:00
#!/usr/bin/env bash
level() {
busctl --system get-property org.freedesktop.UPower /org/freedesktop/UPower/devices/battery_BAT0 org.freedesktop.UPower.Device Percentage | sed "s/d //"
}
icon-name() {
busctl --system get-property org.freedesktop.UPower /org/freedesktop/UPower/devices/battery_BAT0 org.freedesktop.UPower.Device IconName | sed -E "s/(s )|\"//g"
}
if [ "$1" = "check" ]; then
echo $(level)%
exit
fi
while true; do
icon_name=$(icon-name)
if echo $icon_name | grep -qv charging && echo $icon_name | grep -q caution; then
ffplay /usr/share/sounds/freedesktop/stereo/dialog-warning.oga -autoexit -nodisp -hide_banner -v -8 >&- 2>&-
fi
sleep 30
done