#!/bin/sh
set -eu
name_from_desc() {
LANG=C pactl list sinks \
| awk 'BEGIN {FS=": "} /Name:/ {name=$2} /Description:/ {print name, ":", $2}' \
| while IFS=' : ' read name desc; do
if [ "$desc" = "$1" ]; then echo "$name"; fi
done
}
id_from_name() {
pw-cli i "$1" | awk '/id:/ {print $2}'
}
ret=$(LANG=C pactl list sinks | awk 'BEGIN {FS=": "} /Description:/ {print $2}' | tofi)
wpctl set-default $(id_from_name $(name_from_desc "$ret"))
I don't get how that case statement of yours is even supposed to work. I'm pretty sure that's just a syntax error. I guess you want to map from description to name? But that's not remotely what that does.
I made a better solution in my post that works perfectly... and is better for me because it isn't a script (I don't like adding additional dotfiles) sorry for the unnecessary effort.