nixos/home/scripts/batlvl.sh

13 lines
336 B
Bash
Raw Normal View History

2024-04-21 09:46:33 +00:00
#!/usr/bin/env bash
ac_status=$(cat /sys/class/power_supply/AC/online)
bat_status=$(cat /sys/class/power_supply/BAT0/status)
bat_lvl=$(cat /sys/class/power_supply/BAT0/capacity)
if (("$ac_status" == 0)); then
echo "$bat_status - $bat_lvl%"
else
if [ "$bat_lvl" -lt "90" ]; then
echo "$bat_status - $bat_lvl%"
fi
fi