diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery
index 58652d8..ea79f4f 100755
--- a/.local/bin/statusbar/sb-battery
+++ b/.local/bin/statusbar/sb-battery
@@ -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 - NOW!" ;;
+ 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 - NOW!" ;;
esac
}