Skip to content

Instantly share code, notes, and snippets.

@cemulate
Last active September 13, 2025 17:31
Show Gist options
  • Select an option

  • Save cemulate/fe40e63fd2d8b4f92ee060acb8465055 to your computer and use it in GitHub Desktop.

Select an option

Save cemulate/fe40e63fd2d8b4f92ee060acb8465055 to your computer and use it in GitHub Desktop.
One-liner to select and set wireplumber's default sink using `tofi` (or `rofi`).

One-liner to change the wireplumber's default sink using tofi (or rofi).

Uses jq to grab the audio sinks' names and ids from pw-dump and filters though your menu application of choice.

The final pipe uses ifne (from moreutils on arch) to only run the final wpctl command if the choice from tofi was non-empty (e.g., not cancelled or aborted). This final line can also be used as a general recipe to run any command with input from tofi on the same condition that the result was non-empty.

pw-dump | jq -r '.[] | select(.info.props."media.class" == "Audio/Sink") | [ .id, .info.props."node.description" ] | join(": ")' | tofi | cut -f 1 -d ':' | ifne xargs -I {} wpctl set-default {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment