i3, add a battery nagging notification which expands upon existing functions.
This commit is contained in:
Executable
+34
@@ -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
|
||||
Reference in New Issue
Block a user