#!/bin/sh Threshold=5 GetBatteryCapacity() { File="$(find /sys/class/power_supply \ -maxdepth 1 \ -type l \ -name 'BAT*' | head -n 1)" cat "$File"/capacity } PrevCapacity="$(GetBatteryCapacity)" [ "$PrevCapacity" ] || exit 1 while true do Capacity="$(GetBatteryCapacity)" if [ "$Capacity" -lt "$PrevCapacity" ] then if [ "$Capacity" -le "$Threshold" ] then HostName="$(hostname)" if [ "$HostName" = "spring" ] then setsid doas /usr/sbin/zzz -Z fi fi PrevCapacity="$Capacity" fi done