nixos/home/scripts/batlvl.sh
2024-04-21 11:46:33 +02:00

13 lines
336 B
Bash

#!/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