bin: add source to sway_volume

This commit is contained in:
Konstantin Koslowski 2021-05-14 12:00:51 +02:00
parent 2765fdd6cf
commit 3d56ea7e62

View file

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
source $HOME/.config/sway/bin/sway_helpers source $HOME/.config/sway/bin/sway_helpers
SINK=$(pactl info | grep "Default Sink" | cut -d ' ' -f 3) SINK=$(pactl info | grep "Default Sink" | cut -d ' ' -f 3)
SOURCE=$(pactl info | grep "Default Source" | cut -d ' ' -f 3)
ICON_PATH=$HOME/.local/share/icons/Tela-circle-dark/16/actions ICON_PATH=$HOME/.local/share/icons/Tela-circle-dark/16/actions
NOTIFY_APP="dunstify -a volume -h string:x-dunst-stack-tag:volume" NOTIFY_APP="dunstify -a volume -h string:x-dunst-stack-tag:volume"
APP="pavucontrol" APP="pavucontrol"
@ -12,28 +13,29 @@ VOL1="●"
VOL2="◌" VOL2="◌"
function notify() { function notify() {
VOLUME=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep -oE '[0-9]*%' | head -n 1 | sed 's/%//') SINK_VOLUME=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep -oE '[0-9]*%' | head -n 1 | sed 's/%//')
SOURCE_VOLUME=$(pactl list sources | grep "Name: $SOURCE" -A 8 | grep -oE '[0-9]*%' | head -n 1 | sed 's/%//')
MUTE=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep 'Mute:' | cut -d " " -f 2) MUTE=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep 'Mute:' | cut -d " " -f 2)
SOURCE_MUTE=$(pactl list sources | grep "Name: $SOURCE" -A 8 | grep 'Mute:' | cut -d " " -f 2)
echo $MUTE ICON=$ICON_PATH/audio-volume-high.svg
SINK_ICON=""
ICON=""
TITLE=""
if [ "$MUTE" = "yes" ]; then if [ "$MUTE" = "yes" ]; then
ICON=$ICON_PATH/audio-volume-muted.svg ICON=$ICON_PATH/audio-volume-muted.svg
TITLE="${VOLUME}%" elif [ $SINK_VOLUME -le 33 ]; then
elif [ $VOLUME -le 33 ]; then
ICON=$ICON_PATH/audio-volume-low.svg ICON=$ICON_PATH/audio-volume-low.svg
TITLE="${VOLUME}%" SINK_ICON=""
elif [ $VOLUME -le 67 ]; then elif [ $SINK_VOLUME -le 67 ]; then
ICON=$ICON_PATH/audio-volume-medium.svg ICON=$ICON_PATH/audio-volume-medium.svg
TITLE="${VOLUME}%" SINK_ICON=""
else
ICON=$ICON_PATH/audio-volume-high.svg
TITLE="${VOLUME}%"
fi fi
SOURCE_ICON=""
if [ "$SOURCE_MUTE" = "yes" ]; then
SOURCE_ICON=""
fi
TITLE="${SINK_ICON} ${SINK_VOLUME}% / ${SOURCE_ICON} ${SOURCE_VOLUME}%"
# $NOTIFY_APP -i $ICON -a "Volume" "$TEXT" # $NOTIFY_APP -i $ICON -a "Volume" "$TEXT"
$NOTIFY_APP -i $ICON "$TITLE" "$(getProgressString 10 "$VOL1" "$VOL2" $VOLUME)" $NOTIFY_APP -i $ICON "$TITLE" "$(getProgressString 10 "$VOL1" "$VOL2" $SINK_VOLUME)"
} }
## helpers ## helpers
@ -53,11 +55,13 @@ if [ -z "$SINK" ]; then
fi fi
case $1 in case $1 in
# decrease
d*) d*)
pactl set-sink-volume $SINK -5% pactl set-sink-volume $SINK -5%
paplay $SOUND & paplay $SOUND &
notify notify
;; ;;
# increase
i*) i*)
VOLUME=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep -oE '[0-9]*%' | head -n 1 | sed 's/%//') VOLUME=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep -oE '[0-9]*%' | head -n 1 | sed 's/%//')
INC=$((100 - $VOLUME)) INC=$((100 - $VOLUME))
@ -68,11 +72,19 @@ case $1 in
paplay $SOUND & paplay $SOUND &
notify notify
;; ;;
# mute
m*) m*)
pactl set-sink-mute $SINK toggle pactl set-sink-mute $SINK toggle
paplay $SOUND & paplay $SOUND &
notify notify
;; ;;
# source-mute
s*)
pactl set-source-mute $SOURCE toggle
paplay $SOUND &
notify
;;
# show gui
gui) gui)
_check_app $APP _check_app $APP
_toggle $APP _toggle $APP