12 lines
226 B
Bash
Executable File
12 lines
226 B
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Print battery percentage to stdout
|
|
|
|
set -e
|
|
|
|
if [ "$(uname -s)" = "Darwin" ]; then
|
|
pmset -g batt | tail -n 1 | grep -Eo "\d+%" | cut -d% -f1
|
|
else # Linux
|
|
cat /sys/class/power_supply/BAT0/capacity
|
|
fi
|