Skip to content

MehmetNuri/audio-output-switcher

Repository files navigation

Audio Output Switcher (GNOME Shell Extension)

🌍 Türkçe README

A keyboard shortcut (default Super + Alt + O) opens a centered switcher in the middle of the screen — just like the Super+Space keyboard-layout switcher. While the shortcut's modifier keys (Super+Alt) are held, pressing the shortcut again (or the arrow keys) cycles through the devices; releasing the keys applies the selected audio output device. There is no panel icon.

For GNOME Shell 42 / 43 / 44 (including Ubuntu 22.04).

Screenshots

The switcher, opened with the shortcut:

Audio Output Switcher — switcher popup

Preferences (change the shortcut):

Audio Output Switcher — preferences

Usage

  • Super + Alt + O → the switcher opens with the next device pre-selected.
  • Release the keys immediately → switch to that device (fast toggle between two).
  • Keep the modifiers held and tap the shortcut again / use arrow keys → cycle.
  • Esc → cancel without changing anything. Clicking outside also dismisses it.

Why it is safe / cannot lock up

It uses the same SwitcherPopup mechanism as Alt+Tab / Super+Space. It does not create a custom full-screen modal. Esc cancels, releasing the modifier selects, and if the input grab cannot be acquired it returns safely — it cannot lock up the screen.

The device list matches the GNOME Sound settings exactly: the available output devices (Gvc.MixerUIDevice) tracked via output-added / output-removed. Unavailable ports (e.g. an HDMI/DP output with nothing plugged in) are hidden.

Languages

The UI is translatable via gettext. Bundled translations: English (source), Turkish (tr). To add a language, translate po/audio-output-switcher.pot into po/<lang>.po and compile it to locale/<lang>/LC_MESSAGES/audio-output-switcher.mo.

Install

cd /PATH/TO/audio-output-switcher
chmod +x install.sh uninstall.sh
sh install.sh        # or ./install.sh

install.sh validates the JS syntax, JSON and schema first, and only then copies the files.

Loading the new code (important)

A running GNOME Shell does not automatically reload updated JS into memory. gnome-extensions disable/enable does not re-import the module either — it only re-runs enable(). To load code changes:

  • X11 / Xorg: Alt + F2rEnter (windows are preserved).
  • Wayland: log out and back in.

Session type: echo $XDG_SESSION_TYPE

Recovery (no hard reboot required)

On X11, if the shell ever freezes:

  1. Ctrl + Alt + F3 (switch to a TTY)
  2. killall -3 gnome-shell (the shell restarts, your session is preserved)
  3. Ctrl + Alt + F2 (back to the desktop)

Settings

gnome-extensions prefs audio-output-switcher@mehmetnuri.github.io

Click the button and press a new combination. Esc cancels, Backspace removes.

Uninstall

sh uninstall.sh

Testing (optional, safe)

Without touching your main session, test in a nested shell:

dbus-run-session -- gnome-shell --nested --wayland

Debugging

journalctl -f -o cat /usr/bin/gnome-shell

Technical notes

  • UI: SwitcherPopup (same class as Alt+Tab / Super+Space) — cannot lock up.
  • Device switching: Gvc.MixerControl.change_output(uiDevice) (the Settings method). No external tool (pactl) or subprocess — pure native Gvc API.
  • Not for GNOME 45+ (which requires ES modules).

License

GPL-3.0-or-later.

About

A keyboard shortcut (default Super+Alt+O) opens a Super+Space style switcher to quickly change the default audio output device. Shows the same device list as GNOME Sound settings. No panel icon; no external tools (no pactl/subprocess).

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors