You are not logged in.
Pages: 1
What would be best way to show low battery warning on graphical desktop environment?
Currently system just shuts down when battery runs out. No suspend nor sleep but it just shuts down losing all the unsaved data.
I am using Budgie desktop. Budgie's power management offers no solution for this.
Last edited by amatika (2020-10-05 06:37:49)
Offline
You could poll the battery w/ https://www.archlinux.org/packages/comm … 6_64/acpi/ and act accordingly w/ a simple bash script.
For display you could use https://www.archlinux.org/packages/comm … sdbattery/ https://www.archlinux.org/packages/comm … cbatticon/ or just conky.
Offline
Ended up this solution. Seems to work.
battery_test.sh
#!/bin/bash
battery_level=`acpi | grep -oP '(?<=, )\d+(?=%)'`
if [ "$battery_level" -le 10 ]
then
notify-send "Battery low. Battery level is ${battery_level}%!"
elif [ "$battery_level" -le 3 ]
then
notify-send "Battery critical. Battery level is ${battery_level}%! Suspending..."
sleep 5
systemctl suspend
fiCrontab:
PATH=/usr/bin
*/5 * * * * XDG_RUNTIME_DIR=/run/user/$(id -u) /home/amatika/scripts/battery_test.shLast edited by amatika (2020-10-11 18:54:06)
Offline
Pages: 1