mirror of
https://git.adityakumar.xyz/dwmbar.git
synced 2024-11-21 18:12:53 +00:00
36 lines
898 B
Text
36 lines
898 B
Text
|
#!/bin/bash
|
||
|
|
||
|
# Prints out the volume percentage
|
||
|
|
||
|
VOLUME_WIDTH=15
|
||
|
VOLUME_SLIDER='|'
|
||
|
VOLUME_RAIL='-'
|
||
|
VOLUME_MUTED='muted'
|
||
|
|
||
|
PREFIX='VOL'
|
||
|
|
||
|
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 ))
|
||
|
|
||
|
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
|
||
|
done
|
||
|
fi
|
||
|
|
||
|
echo "$PREFIX$BAR"
|
||
|
}
|
||
|
|
||
|
get_volume
|