dotfiles/script/batinfo

12 lines
226 B
Plaintext
Raw Permalink Normal View History

2023-05-31 04:52:57 +00:00
#!/usr/bin/env bash
#
# Print battery percentage to stdout
set -e
2023-10-07 08:43:32 +00:00
if [ "$(uname -s)" = "Darwin" ]; then
2023-11-21 08:19:40 +00:00
pmset -g batt | tail -n 1 | grep -Eo "\d+%" | cut -d% -f1
2023-05-31 04:52:57 +00:00
else # Linux
2023-10-07 08:43:32 +00:00
cat /sys/class/power_supply/BAT0/capacity
2023-05-31 04:52:57 +00:00
fi