nixos/home/scripts/batlvl.sh
Torjus Håkestad e1049f0a16
Some checks failed
pre-commit / pre-commit (push) Failing after 23s
pre-commit / pre-commit (pull_request) Failing after 14m39s
Rice laptop
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