]>
permondes.de Git - TermuxBatteryStatus.git/blob - batterie-status.scr
3 # On Android devices with Termux, notify the user when the device is charged to 80%
7 # get the battery status and generate variables out of the returned jason data
8 # then analyse the response
9 # terminate loop when device is not charging or reached >79%
13 termux-battery-status | \
14 jq -r 'to_entries | .[] | map_values(tostring) | .key + "=\"" + .value + "\"" ' )"
15 if [ "$status" != "CHARGING" ]
17 elif [ $percentage -gt 79 ]
23 # vibrate shortly, show details in the notification area
24 termux-notification
--id bs
--title "Termux Battery-Status" --vibrate 200 \
25 -c "$(date +"%e.
%m.
%Y
%k
:%M
:%S
"): $status, $plugged, $percentage%, $health health, $temperature °C"
27 # tell status and percentage in english, slightly slower speed than standard
28 termux-tts-speak
-l en
-r 0.95 "$status, $plugged, $percentage%"
33 # -r : output not in json format, raw
34 # to_entries: converts an object to an array of key-value pairs.
35 # .[] : returns all of the elements of an array
36 # map_values(tostring) : convert numbers to strings, needed for the + later-on
37 # .key=.value : generate the variable assignment