2
2
[PATCH 1/2] add notify-send message when battery is lower than 8% and not charging
---
configs/default_hooks/sxmo_hook_battery.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/configs/default_hooks/sxmo_hook_battery.sh b/configs/default_hooks/sxmo_hook_battery.sh
index e040f6d..4ceea4c 100755
--- a/configs/default_hooks/sxmo_hook_battery.sh
+++ b/configs/default_hooks/sxmo_hook_battery.sh
@@ -24,6 +24,13 @@ device_changed() {
sxmo_hook_statusbar.sh battery "$name" "$state" "$percentage"
}
+ # battery low warning
+ PERCENTAGE=$(upower -d | awk '/percentage/; /^$/ {exit}' | sed 's/[^0-9]//g')
+ STATE=$(upower -d | awk '/state/; /^$/ {exit}' | sed 's/state://g;s/ //g')
+
+ if [ $STATE = "discharging" ] && [ $PERCENTAGE -lt 8 ]; then
+ notify-send -t 5000 --urgency=critical "BATTERY is LOW" "(+_+) I will die soon"
+ fi
object="$1"
event="$2"
--
2.43.0
Fwd: [PATCH 1/2] add notify-send message when battery is lower than 8% and not charging
please ignore this....
sorry... it was stock in my commit history
-------- Original Message -------- SUBJECT: [PATCH 1/2] add notify-send
message when battery is lower than 8% and not charging DATE: 2024-04-15
21:13 FROM: magdesign <hallo@magdesign.ch > TO:
~mil/sxmo-devel@lists.sr.ht CC: magdesign <hallo@magdesign.ch > ---
configs/default_hooks/sxmo_hook_battery.sh | 7 +++++++ 1 file changed, 7
insertions(+) diff --git a/configs/default_hooks/sxmo_hook_battery.sh
b/configs/default_hooks/sxmo_hook_battery.sh index e040f6d..4ceea4c
100755 --- a/configs/default_hooks/sxmo_hook_battery.sh +++
b/configs/default_hooks/sxmo_hook_battery.sh @@ -24,6 +24,13 @@
device_changed() { sxmo_hook_statusbar.sh battery "$name" "$state"
"$percentage" } +# battery low warning +PERCENTAGE=$(upower -d | awk
'/percentage/; /^$/ {exit}' | sed 's/[^0-9]//g') +STATE=$(upower -d |
awk '/state/; /^$/ {exit}' | sed 's/state://g;s/ //g') + +if [ $STATE =
"discharging" ] && [ $PERCENTAGE -lt 8 ]; then + notify-send -t 5000
--urgency=critical "BATTERY is LOW" "(+_+) I will die soon" +fi
object="$1" event="$2"
I sit on a similar patch for some time, with a saner implementation imo.
I prefer to merge this. It does not check the upower status, which I
think make it simplest, but enough for now. Feel free to improve it.
Marked as superseded !