fix: notification when battery runs low
This commit is contained in:
parent
d773272331
commit
e0e386c9dd
@ -16,9 +16,18 @@
|
|||||||
# Also sends a notification if battery running low
|
# Also sends a notification if battery running low
|
||||||
|
|
||||||
notify() { \
|
notify() { \
|
||||||
case "$(cat "$x")" in
|
now=$(date +%s)
|
||||||
1[0-9]) notify-send -u "normal" "Battery is $status and running low ($capacity%)" "Please plug your computer to a power source" ;;
|
if [ -e $XDG_CONFIG_HOME/batteryupdate ]; then
|
||||||
[0-9]) notify-send -u "critical" "Battery is $status and dangerously low ($capacity%)" "Please plug your computer to a power source - <b>NOW!</b>" ;;
|
old=$(cat $XDG_CONFIG_HOME/batteryupdate)
|
||||||
|
delta=$(expr $now - $old)
|
||||||
|
else
|
||||||
|
delta=$now
|
||||||
|
fi
|
||||||
|
[ 300 -gt $delta ] && return;
|
||||||
|
echo $now > $XDG_CONFIG_HOME/batteryupdate
|
||||||
|
case "$capacity" in
|
||||||
|
1[0-9]) notify-send -u "normal" "Battery is running low ($capacity%)" "Please plug your computer to a power source" ;;
|
||||||
|
[0-9]) notify-send -u "critical" "Battery is dangerously low ($capacity%)" "Please plug your computer to a power source - <b>NOW!</b>" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user