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
|
||||
|
||||
notify() { \
|
||||
case "$(cat "$x")" in
|
||||
1[0-9]) notify-send -u "normal" "Battery is $status and running low ($capacity%)" "Please plug your computer to a power source" ;;
|
||||
[0-9]) notify-send -u "critical" "Battery is $status and dangerously low ($capacity%)" "Please plug your computer to a power source - <b>NOW!</b>" ;;
|
||||
now=$(date +%s)
|
||||
if [ -e $XDG_CONFIG_HOME/batteryupdate ]; then
|
||||
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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user