battery_nag.sh, add output.
This commit is contained in:
@@ -2,6 +2,12 @@
|
|||||||
# 20260819 Hyperling
|
# 20260819 Hyperling
|
||||||
# Call notify-send to alert the user every 5 minutes once the battery is low
|
# Call notify-send to alert the user every 5 minutes once the battery is low
|
||||||
|
|
||||||
|
echo "`date` - Loading Functions"
|
||||||
|
|
||||||
|
#which battery.function
|
||||||
|
source battery.function
|
||||||
|
|
||||||
|
echo "`date` - Parsing Parameters"
|
||||||
|
|
||||||
# Default to 20%.
|
# Default to 20%.
|
||||||
alert=20
|
alert=20
|
||||||
@@ -15,8 +21,9 @@ if [[ -n "$2" ]]; then
|
|||||||
sleep="$2"
|
sleep="$2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#which battery.function
|
echo "`date` - Alerting every ${sleep} seconds when under ${alert}%."
|
||||||
source battery.function
|
|
||||||
|
echo "`date` - Starting Loop"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
|
||||||
@@ -24,10 +31,16 @@ while true; do
|
|||||||
batt=${batt//%/}
|
batt=${batt//%/}
|
||||||
|
|
||||||
if (( batt <= alert )); then
|
if (( batt <= alert )); then
|
||||||
title="Battery has dropped below ${alert}%"
|
title="Battery is below ${alert}%!"
|
||||||
message="Currently at ${batt}%"
|
message="Currently at ${batt}%."
|
||||||
cmd="`which fyi 2>/dev/null || which notify-send 2>/dev/null`"
|
cmd="`which fyi 2>/dev/null || which notify-send 2>/dev/null`"
|
||||||
|
|
||||||
$cmd "$title" "$message"
|
$cmd "$title" "$message"
|
||||||
|
status="$?"
|
||||||
|
|
||||||
|
echo "`date` - Nag returned status ${status}."
|
||||||
|
else
|
||||||
|
echo "`date` - Battery at ${batt}%, did not nag."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep $sleep
|
sleep $sleep
|
||||||
|
|||||||
Reference in New Issue
Block a user