From 6fbb6273368b7a7d5b04d3d34f417db36dda3b37 Mon Sep 17 00:00:00 2001 From: Joren Date: Mon, 23 Sep 2024 14:44:38 +0200 Subject: [PATCH] first commit --- VolumeMenu/volume | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 VolumeMenu/volume diff --git a/VolumeMenu/volume b/VolumeMenu/volume new file mode 100755 index 0000000..1d3763a --- /dev/null +++ b/VolumeMenu/volume @@ -0,0 +1,32 @@ +#!/bin/bash + +SINKS=$(pactl list short sinks | awk '{print $2}') + +declare -A sink_map + +options="" +first=true +while read -r sink; do + device=$(echo "$sink") + device_name=$(pactl list sinks | grep -A 20 "$device" | grep "Description:" | awk -F: '{print $2}' | xargs) + + if [ "$first" = true ]; then + options+="$device_name" + first=false + else + options+="\n$device_name" + fi + sink_map["$device_name"]="$device" +done <<< "$SINKS" + +CHOSEN=$(echo -e "$options" | dmenu -l 10 -i -p "Select Audio Output") + +if [ -n "$CHOSEN" ]; then + CHOSEN_SINK=${sink_map["$CHOSEN"]} + pactl set-default-sink "$CHOSEN_SINK" + + for stream in $(pactl list short sink-inputs | awk '{print $1}'); do + pactl move-sink-input "$stream" "$CHOSEN_SINK" + done +fi +