m pactl unload-module module-null-sink
m pactl unload-module module-remap-source
- IFS=" " read -r -a sources <<<"$(pacmd list-sources | sed -rn 's/.*name: <([^>]+).*/\1/p')"
+ IFS=" " read -r -a sources <<<"$(pactl -f json list sources|jq -r '.[].name')"
if (( ! $# )); then
i=0
# unmute desktop output
um() {
- local sink card sedcmd
+ local sink card
sink=$(pactl get-default-sink)
if [[ $sink == auto_null ]]; then
- # guessing there is just one with an off profile. otherwise we will
- # need some other solution, like storing the card identifier that we
- # muted with nap. Or, we could so some hakery with
- # pactl -f json.
- sedcmd='/^[[:space:]]*index:/{s/^[[:space:]]*index://;h};/^[[:space:]]*active profile: <off>$/{g;p;q}'
- card=$(pacmd list-cards | sed -n "$sedcmd")
- m pacmd set-card-profile "$card" output:analog-stereo
+ # this assumes there is just one with an off profile. otherwise we will
+ # need to do something else like storing the card name we care
+ # about somewhere. the nap function picks a card, it could help.
+ card=$(pactl -f json list cards|jq '.[] | select(.active_profile? == "off")|.index')
+ if [[ $card ]]; then
+ m pactl set-card-profile "$card" output:analog-stereo
+ else
+ echo "iank note: no muted card found. still unmuting sink"
+ fi
fi
-
m pactl set-sink-mute @DEFAULT_SINK@ false
rm -f /tmp/ianknap
}