blob: ecc38ea454213619d69712c8945d1345908f77c9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#!/bin/sh -e
dump="$(pw-dump)"
devices="$(echo "$dump" | jq -r '.[].info.props | select((."api.alsa.pcm.stream"=="playback") or (."api.bluez5.connection"=="connected"))')"
echo "$devices"
descriptions="$(echo "$devices" | jq -r '."node.description"')"
default_name="$(echo "$dump" | jq -r '.[] | select(.props."metadata.name"=="default") | .metadata.[] | select(.key=="default.audio.sink") | .value.name')"
default_description="$(echo "$devices" | jq -r ". | select(.\"node.name\"==\"$default_name\") | .\"node.description\"")"
picked_description="$(printf "%s\n%s" "$default_description" "$descriptions" | awk '!seen[$0]++' | dmenu -i -l 20 -p "Audio output")"
[ -z "$picked_description" ] && exit 1
picked_id="$(echo "$devices" | jq -r ". | select (.\"node.description\"==\"$picked_description\") | .\"object.id\"")"
[ -z "$picked_id" ] && exit 1
wpctl set-default "$picked_id"
|