Open sphaero opened 5 years ago
.config/systemd/user/low-battery.service
[Unit]
Description=Check for low battery and hibernate if too low
[Service]
ExecStart=%h/bin/low-battery.sh
[Install]
WantedBy=multi-user.target
.config/systemd/user/low-battery.timer
[Unit]
Description=Runs every 5 minutes - needed by low-battery.service
[Timer]
OnCalendar=*:0/5
Persistent=true
[Install]
WantedBy=timers.target
~/bin/low-battery.sh
#!/bin/sh
STATUS=`cat /sys/class/power_supply/BAT0/status`
CAPACITY=`cat /sys/class/power_supply/BAT0/capacity`
if [ "$STATUS" = Discharging -a "$CAPACITY" -lt 5 ]; then
notify-send -c critical "Hibernating" "Hibernating due to low battery" &> /dev/null
logger "Hibernating due to low battery" &> /dev/null
systemctl hibernate
fi
as we've installed as little as possible there's nothing responding to low battery situations.
best aproach is some timed script?