Skip to content

Instantly share code, notes, and snippets.

@gavlooth
Created November 19, 2023 10:29
Show Gist options
  • Save gavlooth/2f962e7410ef5036e6c5f6c5fb87831c to your computer and use it in GitHub Desktop.
Save gavlooth/2f962e7410ef5036e6c5f6c5fb87831c to your computer and use it in GitHub Desktop.
Get the name of current audio device
#!/bin/env zsh
pactl --format=json list cards |jq -c '.[] | select (.name | contains('\"$(pactl --format=json info | jq . |jq ".default_sink_name" | cut -d"." -f2)\"'))?' | jq '.properties."device.description"' | xargs -n 1 echo "Audio Device: "
@gavlooth
Copy link
Author

One liner that uses pactl and jq to get the "device name" for the current audio devices. It takes advadage of pactl json output option and jq's superior json manipulation capabilities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment