From ab2d39c700270340e2b7451fc7ce14a3c1808497 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Wed, 19 Aug 2026 14:01:41 -0700 Subject: [PATCH] i3, add a battery nagging notification which expands upon existing functions. --- files/scripts/battery_nag.sh | 34 ++++++++++++++++++++++++++++++++++ files/settings/i3.config | 7 +++++-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100755 files/scripts/battery_nag.sh diff --git a/files/scripts/battery_nag.sh b/files/scripts/battery_nag.sh new file mode 100755 index 0000000..f5b7f18 --- /dev/null +++ b/files/scripts/battery_nag.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# 20260819 Hyperling +# Call notify-send to alert the user every 5 minutes once the battery is low + + +# Default to 20%. +alert=20 +if [[ -n "$1" ]]; then + alert="$1" +fi + +# Default to 5 minutes. +sleep=300 +if [[ -n "$2" ]]; then + sleep="$2" +fi + +#which battery.function +source battery.function + +while true; do + + batt=`battery-display` + batt=${batt//%/} + + if (( batt <= alert )); then + title="Battery has dropped below ${alert}%" + message="Currently at ${batt}%" + cmd="`which fyi 2>/dev/null || which notify-send 2>/dev/null`" + $cmd "$title" "$message" + fi + + sleep $sleep +done diff --git a/files/settings/i3.config b/files/settings/i3.config index ea1b897..1b422c9 100644 --- a/files/settings/i3.config +++ b/files/settings/i3.config @@ -362,7 +362,10 @@ exec --no-startup-id "sleep 02; killall wireplumber; wireplumber >~/Reports/wire exec --no-startup-id "sleep 03; killall pipewire-pulse; pipewire-pulse >~/Reports/pipewire-pulse.log 2>&1 &" # Wallpaper -exec --no-startup-id feh --recursive --randomize --bg-fill ~/Pictures/Wallpapers +exec_always --no-startup-id feh --recursive --randomize --bg-fill ~/Pictures/Wallpapers # Compositor -exec_always --no-startup-id picom -f +exec_always --no-startup-id "killall picom; picom -f" + +# Battery +exec_always --no-startup-id "killall battery_nag.sh; battery_nag.sh"