wpctl set-default $(pw-dump | jaq -r '.[]|select(.type==\"PipeWire:Interface:Node\" and .info.props[\"media.class\"]==\"Audio/Sink\")|[.id,.info.props[\"node.name\"],.info.props[\"node.description\"]]|@tsv' | awk -F'\\t' -v d=\"$(wpctl inspect @DEFAULT_AUDIO_SINK@|awk -F'\"' '/node.name/{print $2;exit}')\" 'BEGIN{c=\"tofi --prompt-text \\\"Audio Device: \\\" --height 40% --width 40% --auto-accept-single true\"}$2!=d&&$2!=\"easyeffects_sink\"{a[$3]=$1;print $3|&c}END{close(c,\"to\");c|&getline p;print a[p];system(\"notify-send --urgency=low --icon=/run/current-system/sw/share/icons/Flat-Remix-Red-Dark/panel/audio-volume-high-symbolic.svg \\\"p\\\" -h string:x-canonical-private-synchronous:sink-state\")} ' >/dev/null && pw-play --volume=0.2 /run/current-system/sw/share/sounds/freedesktop/stereo/audio-volume-change.oga >/dev/null &!"

there’s probably a lot to improve here, took forever to get this working, did not do a cleanup pass, jfc this took forever, replace tofi with your menu of choice, thought people should have this.

wishlist: change the icon based on volume level

OC by @[email protected]

  • Victor
    link
    fedilink
    arrow-up
    2
    ·
    6 days ago

    What’s your definition of “pure” in this case? I’m just wondering because you are using both jaq and awk here.

    • Victor
      link
      fedilink
      arrow-up
      1
      ·
      6 days ago

      By the way, any advantages of jaq over jq? Over yq?