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;devs++;print $3|&c}END{if(devs>1){close(c,"to");c|&getline p;if(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")}}else if(devs==1){for(k in a){print a[k];system("notify-send --urgency=low --icon=/run/current-system/sw/share/icons/Flat-Remix-Red-Dark/panel/audio-volume-high-symbolic.svg \""k"\" -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

  • Communist@lemmy.frozeninferno.xyzOP
    link
    fedilink
    English
    arrow-up
    4
    ·
    1 day ago

    I don’t like doing that because i’m working on nixos which already makes it complicated but i also have a script that fully sets up my entire system and that would add some complexity to that, plus i just have a strange aversion to making it a bash script purely because it would be the only common function in my setup that’s on a bash script

    and it wouldn’t be that hard to convert it to one for future debugging anyway

    • INeedMana@piefed.zip
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 day ago

      I can see how that could be a hassle on nixos and if you don’t have more scripts

      FWIW, I use chezmoi for stuff like this, I guess it might be easier to make it work with nixos by setting up chezmoi in HOME, instead of defining scripts directly