You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
725 B

5 years ago
#!/usr/bin/env sh
UPDATEFILE=/tmp/sxmo_bar
touch $UPDATEFILE
while :
do
PCT=$(cat /sys/class/power_supply/*-battery/capacity)
5 years ago
BATSTATUS=$(
cat /sys/class/power_supply/*-battery/status |
cut -c1
5 years ago
)
VOL=$(
echo "$(amixer sget Headphone || amixer sget Speaker)" |
5 years ago
grep -oE '([0-9]+)%' |
tr -d ' %' |
awk '{ s += $1; c++ } END { print s/c }' |
xargs printf %.0f
)
TIME=$(date +%R)
BAR=" V${VOL} ${BATSTATUS}${PCT}% ${TIME}"
xsetroot -name "$BAR"
inotifywait -e MODIFY $UPDATEFILE & sleep 5 & wait -n
pgrep -P $$ | xargs kill -9
done