Changed volumebar slightly

This commit is contained in:
Archie Hilton (thytom) 2019-10-22 00:17:37 +01:00
parent e611703e03
commit 9a22deb487

View file

@ -2,33 +2,38 @@
# Prints out the volume percentage
VOLUME_WIDTH=15
VOLUME_SLIDER='|'
VOLUME_RAIL='-'
# Dependencies: bc
VOLUME_WIDTH=9
VOLUME_SLIDER='⬤'
VOLUME_RAIL='◯'
VOLUME_MUTED='muted'
PREFIX='VOL'
PREFIX=''
# If volume is >100
ALERT='!!!'
get_volume(){
active_sink=$(pacmd list-sinks | awk '/* index:/{print $3}')
curStatus=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | awk '/muted/{ print $2}')
volume=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | grep 'volume:' | grep -E -v 'base volume:' | awk -F : '{print $3}' | grep -o -P '.{0,3}%'| sed s/.$// | tr -d ' ')
slider_position=$(( $volume / $VOLUME_WIDTH ))
slider_position=$(echo "scale=scale(1.0); x = ($volume / 100) * $VOLUME_WIDTH; scale=scale(1); x / 1" | bc)
if [ "${curStatus}" = 'yes' ]
then
echo "$VOLUME_MUTED"
exit 0
else
for i in $(seq 1 $slider_position); do
BAR=$BAR$VOLUME_RAIL
done
BAR=$BAR$VOLUME_SLIDER
for i in $(seq $slider_position $VOLUME_WIDTH); do
BAR=$BAR$VOLUME_RAIL
for i in $(seq 1 $VOLUME_WIDTH); do
[[ $i = $slider_position ]] && BAR=$BAR$VOLUME_SLIDER
[[ $i < $slider_position ]] && BAR=$BAR$VOLUME_SLIDER
[[ $i > $slider_position ]] && BAR=$BAR$VOLUME_RAIL
done
fi
[[ $volume -gt 100 ]] && PREFIX=$PREFIX$ALERT
echo "$PREFIX$BAR"
}