{"id":30857781,"url":"https://github.com/miro-wq/ubuntu-audio-toggle","last_synced_at":"2026-05-05T08:31:48.427Z","repository":{"id":309265918,"uuid":"1035649822","full_name":"Miro-wq/ubuntu-audio-toggle","owner":"Miro-wq","description":"A quick solution on how to change the audio output in Ubuntu using two keyboard shortcuts","archived":false,"fork":false,"pushed_at":"2025-08-10T21:29:30.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-10T23:25:28.646Z","etag":null,"topics":["audio","json","linux","toggle","ubuntu"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Miro-wq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-10T21:06:36.000Z","updated_at":"2025-08-10T21:29:33.000Z","dependencies_parsed_at":"2025-08-10T23:25:30.437Z","dependency_job_id":"776b08b1-5244-405e-bcb5-ddbf05ba227f","html_url":"https://github.com/Miro-wq/ubuntu-audio-toggle","commit_stats":null,"previous_names":["miro-wq/ubuntu-audio-toggle"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Miro-wq/ubuntu-audio-toggle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miro-wq%2Fubuntu-audio-toggle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miro-wq%2Fubuntu-audio-toggle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miro-wq%2Fubuntu-audio-toggle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miro-wq%2Fubuntu-audio-toggle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Miro-wq","download_url":"https://codeload.github.com/Miro-wq/ubuntu-audio-toggle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miro-wq%2Fubuntu-audio-toggle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274045975,"owners_count":25212978,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","json","linux","toggle","ubuntu"],"created_at":"2025-09-07T13:35:42.495Z","updated_at":"2026-05-05T08:31:48.379Z","avatar_url":"https://github.com/Miro-wq.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quickly change audio output in Ubuntu (PipeWire) without problems with dynamic IDs\nProblem:\n\nIn PipeWire, commands like ```wpctl set-default 33``` only work until the next restart, because the numbers (33, 81, etc.) change every time.\n\nSolution:\n\nWe use pw-dump (which provides a JSON list of all audio nodes) + jq to identify the sink by description (name visible in wpctl status), not by ID.\nThus, the script works even if the IDs change.\n\nInstall ```jq```:\n```bash\nsudo apt update \u0026\u0026 sudo apt install -y jq\n```\n\n## 1. Find out the descriptions of your audio outputs\n\nRun:\n```bash\npw-dump | jq -r '\n  .[] | select(.type==\"PipeWire:Interface:Node\")\n  | select(.info.props[\"media.class\"]==\"Audio/Sink\")\n  | \"\\(.id)\\t\\(.info.props[\"node.name\"])\\t\\(.info.props[\"node.description\"])\"\n'\n```\nSee the result, for example:\n```bash\n33\talsa_output.pci-0000_09_00.4.analog-stereo\tetc... HD Audio Controller Analog Stereo\n81\talsa_output.pci-0000_07_00.1.hdmi-stereo\tetc... HDMI/DP Audio Controller Digital Stereo (HDMI)\n```\n## 2. Create the script for the first output (e.g. Analog / headphones) and save it as ~/.local/bin/audio-to-headphones.sh, or any other name.\n\nMake it executable\n```bash\nchmod +x ~/.local/bin/audio-to-hdmi.sh\n```\nMake two keyboard shortcuts\n\nAdd one for HDMI → Command: ```~/.local/bin/audio-to-hdmi.sh```\n\nAdd one for Analog → Command: ```~/.local/bin/audio-to-headphones.sh```\n\n### Advantages over classic methods:\n- You don't depend on volatile IDs.\n- Works even after update/reboot.\n- Automatically moves all active streams to the new output.\n- Can be run from terminal or shortcut.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiro-wq%2Fubuntu-audio-toggle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiro-wq%2Fubuntu-audio-toggle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiro-wq%2Fubuntu-audio-toggle/lists"}