Last active
March 20, 2023 21:01
-
-
Save abenson/63c88d3ee5a4f0699307cc17d1416cb0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
for bat in /sys/class/power_supply/BAT?/uevent; do | |
_state=$(grep -w POWER_SUPPLY_NAME "$bat" | cut -d= -f2) | |
_charge=$(grep -w POWER_SUPPLY_CHARGE_NOW "$bat" | cut -d= -f2) | |
_full=$(grep -w POWER_SUPPLY_CHARGE_FULL "$bat" | cut -d= -f2) | |
_design=$(grep -w POWER_SUPPLY_CHARGE_FULL_DESIGN "$bat" | cut -d= -f2) | |
printf "$POWER_SUPPLY_NAME Status: %s\n" "${_state}" | |
printf "$POWER_SUPPLY_NAME Charge: %d%%\n" $(( (_charge * 100) / _full )) | |
printf "$POWER_SUPPLY_NAME Health: %d%%\n" $(( (_full * 100) / _design )) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment