19 lines
528 B
Plaintext
19 lines
528 B
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
# adapted from other script i wrote, also in the public domain
|
||
|
if [ "$(uname)" = "Linux" ]; then
|
||
|
# this is a dirty hack.
|
||
|
# acpi | awk '{print $4}' will print the battery percentage,
|
||
|
# and s/,$// strips the trailing comma.
|
||
|
printf "%s\n" "$(acpi | awk '{print $4}' | sed 's/,$//')"
|
||
|
elif [ "$(uname)" = "NetBSD" ]; then
|
||
|
printf "%s\n" "$(envstat -s acpibat0:charge \
|
||
|
| sed 1,2d \
|
||
|
| cut -d ':' -f 2 \
|
||
|
| awk '{print $1}' \
|
||
|
| cut -d '.' -f 1)"
|
||
|
else
|
||
|
printf "%s: unsupported system\n" "$(uname)" 1>&2
|
||
|
exit 1
|
||
|
fi
|