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.

43 lines
1.1 KiB

4 years ago
#!/usr/bin/env sh
pgrep -f sxmo_statusbar.sh | grep -v $$ | xargs kill -9
audiodevice() {
amixer sget Earpiece | grep -E [[]on[]] && echo Earpiece > /dev/null && return
amixer sget Headphone > /dev/null && echo Headphone || echo Speaker
}
4 years ago
sleep 1
4 years ago
UPDATEFILE=/tmp/sxmo_bar
touch $UPDATEFILE
while :
do
# M symbol if modem monitoring is on & modem present
MODEMMON=""
pgrep -f sxmo_modemmonitor.sh && MODEMMON="M "
# Battery pct
PCT=$(cat /sys/class/power_supply/*-battery/capacity)
4 years ago
BATSTATUS=$(
cat /sys/class/power_supply/*-battery/status |
cut -c1
4 years ago
)
# Volume
4 years ago
VOL=$(
echo "$(amixer sget $(audiodevice))" |
4 years ago
grep -oE '([0-9]+)%' |
tr -d ' %' |
awk '{ s += $1; c++ } END { print s/c }' |
xargs printf %.0f
)
# Time
4 years ago
TIME=$(date +%R)
BAR=" ${MODEMMON}V${VOL} ${BATSTATUS}${PCT}% ${TIME}"
4 years ago
xsetroot -name "$BAR"
inotifywait -e MODIFY $UPDATEFILE & sleep 30 & wait -n
4 years ago
pgrep -P $$ | xargs kill -9
done