2019-10-21 22:51:27 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Prints out the volume percentage
|
|
|
|
|
2019-10-21 23:17:37 +00:00
|
|
|
# Dependencies: bc
|
|
|
|
|
|
|
|
VOLUME_WIDTH=9
|
|
|
|
VOLUME_SLIDER='⬤'
|
|
|
|
VOLUME_RAIL='◯'
|
2019-10-21 22:51:27 +00:00
|
|
|
VOLUME_MUTED='muted'
|
|
|
|
|
2019-10-21 23:17:37 +00:00
|
|
|
PREFIX=''
|
|
|
|
|
|
|
|
# If volume is >100
|
|
|
|
ALERT='!!!'
|
2019-10-21 22:51:27 +00:00
|
|
|
|
|
|
|
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 ' ')
|
2019-11-06 14:25:24 +00:00
|
|
|
slider_position=$(python -c "print(($volume / 100) * $VOLUME_WIDTH)")
|
2019-10-21 22:51:27 +00:00
|
|
|
|
|
|
|
if [ "${curStatus}" = 'yes' ]
|
|
|
|
then
|
|
|
|
echo "$VOLUME_MUTED"
|
|
|
|
exit 0
|
|
|
|
else
|
2019-10-21 23:17:37 +00:00
|
|
|
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
|
2019-10-21 22:51:27 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2019-10-21 23:17:37 +00:00
|
|
|
[[ $volume -gt 100 ]] && PREFIX=$PREFIX$ALERT
|
|
|
|
|
2019-10-21 22:51:27 +00:00
|
|
|
echo "$PREFIX$BAR"
|
|
|
|
}
|
|
|
|
|
|
|
|
get_volume
|