ref: 9f9c33d10d88bc328309a5877dcac72c3fa96c1a
parent: ef272e6934a41d82c764e9b8f811be0dc7fb4b58
author: qwx <qwx@sciops.net>
date: Thu Aug 18 20:32:27 EDT 2022
add nopedog: battery watchdog for cron(8)
--- /dev/null
+++ b/bin/nopedog
@@ -1,0 +1,20 @@
+#!/bin/rc
+rfork n
+if(! test -f '#s'/acpi)
+ exit ''
+mount '#s'/acpi /mnt/pm || exit
+if(! test -f /mnt/pm/battery)
+ exit no battery to hand
+awk '
+{
+ if($1 > bat)
+ bat = $1
+}END{
+ if(bat == 0)
+ exit
+ if(bat < 5)
+ system("fshalt")
+ else if(bat < 10)
+ system("window -dx 120 -dy 200 -minx 0 -miny 0 \''label alert; echo FAILURE IS IMMINENT; play /lib/m/mamb/pripyat.evacuation.audio.opus; rc\''")
+}
+' /mnt/pm/battery