#!/bin/sh

list_sinks() {
    env LC_ALL=C pactl list sinks
}

desc=$(
    list_sinks |
    grep -ie "description:" |
    cut -d: -f2 |
    sed 's/^ //g;s/ $//g;' |
    wdmenu -i -p "Output:"
)
device=$(
    list_sinks |
    grep -C2 "Description: $desc"|
    grep Name |
    cut -d: -f2 |
    xargs
)

vol=$(pamixer --get-volume)

pactl set-default-sink "$device"

pamixer --set-volume "$vol"
