andrescidoncha / audio-switcher Goto Github PK
View Code? Open in Web Editor NEWGnome-Shell Extension: Easily switch between your audio inputs/outputs from the system menu
License: GNU General Public License v3.0
Gnome-Shell Extension: Easily switch between your audio inputs/outputs from the system menu
License: GNU General Public License v3.0
Hello,
This is a tricky one that has been bothering me for a few months. I finally decided to look into it.
Running Ubuntu 18.04, I have an Nvidia GPU using proprietary driver with 2 identical HDMI monitors including audio output.
From the System Settings, in sound, I see 2 devices. In audio-switcher, the two HDMI audio out are shown as only one device. The only way to properly select which monitor I want the audio to come from is to use System Settings.
I do not know the first thing about Audio and how it's managed, but I saw something called a "sink" mentioned in the code. I looked in PulseAudio, and there's only one sink for HDMI output:
- index: 0
name: <alsa_output.pci-0000_01_00.1.hdmi-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 9030
volume: front-left: 49808 / 76% / -7,15 dB, front-right: 49808 / 76% / -7,15 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 0,00 ms
max request: 0 KiB
max rewind: 0 KiB
monitor source: 0
sample spec: s16le 2ch 48000Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 1
configured latency: 0,00 ms; range is 0,50 .. 341,33 ms
card: 0 <alsa_card.pci-0000_01_00.1>
module: 7
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "HDMI 0"
alsa.id = "HDMI 0"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "3"
alsa.card = "2"
alsa.card_name = "HDA NVidia"
alsa.long_card_name = "HDA NVidia at 0xdf080000 irq 17"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:01:00.1"
sysfs.path = "/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card2"
device.bus = "pci"
device.vendor.id = "10de"
device.vendor.name = "NVIDIA Corporation"
device.product.id = "10f0"
device.product.name = "GP104 High Definition Audio Controller"
device.string = "hdmi:2"
device.buffering.buffer_size = "65536"
device.buffering.fragment_size = "32768"
device.access_mode = "mmap+timer"
device.profile.name = "hdmi-stereo"
device.profile.description = "Digital Stereo (HDMI)"
device.description = "GP104 High Definition Audio Controller Digital Stereo (HDMI)"
alsa.mixer_name = "Nvidia GPU 83 HDMI/DP"
alsa.components = "HDA:10de0083,14623301,00100100"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: yes)
properties:
device.icon_name = "video-display"
device.product.name = "VG245
"
active port:
After I manually select the other HDMI audio out from system menu, the Sink is replaced by this new one (I have 2 other irrelevant audio outputs, the new sink is added at the end of the index, so it's getting index 3):
- index: 3
name: <alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1>
driver: <module-alsa-card.c>
flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: IDLE
suspend cause:
priority: 9030
volume: front-left: 49808 / 76% / -7,15 dB, front-right: 49808 / 76% / -7,15 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 64,86 ms
max request: 14 KiB
max rewind: 64 KiB
monitor source: 4
sample spec: s16le 2ch 48000Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 1
configured latency: 75,00 ms; range is 0,50 .. 341,33 ms
card: 0 <alsa_card.pci-0000_01_00.1>
module: 7
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "HDMI 1"
alsa.id = "HDMI 1"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "7"
alsa.card = "2"
alsa.card_name = "HDA NVidia"
alsa.long_card_name = "HDA NVidia at 0xdf080000 irq 17"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:01:00.1"
sysfs.path = "/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card2"
device.bus = "pci"
device.vendor.id = "10de"
device.vendor.name = "NVIDIA Corporation"
device.product.id = "10f0"
device.product.name = "GP104 High Definition Audio Controller"
device.string = "hdmi:2,1"
device.buffering.buffer_size = "65536"
device.buffering.fragment_size = "32768"
device.access_mode = "mmap+timer"
device.profile.name = "hdmi-stereo-extra1"
device.profile.description = "Digital Stereo (HDMI 2)"
device.description = "GP104 High Definition Audio Controller Digital Stereo (HDMI 2)"
alsa.mixer_name = "Nvidia GPU 83 HDMI/DP"
alsa.components = "HDA:10de0083,14623301,00100100"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec, available: yes)
properties:
device.icon_name = "video-display"
device.product.name = "VG245
"
active port:
At this point I've decided to come here and ask for you help/advices. Anybody here knows how I can modify the extensions in order to have both HDMI output displayed?
Hi there,
First, thank you for putting together this wonderful extension. I use it everyday and have no problems whatsoever. I was wondering if would be possible (and, hopefully, not to much of a hassle) for you to add a configuration option for a hot key. The user will be able to choose the hot key (or combination of keys) to switch between a audio outputs and inputs. Also, the user will be able to choose which of the currently available input/output audio sources he/she would like to cycle through using said hot key.
This is one feature I miss from my Windows days (I used this in Windows: https://github.com/xenolightning/AudioSwitcher_v1)
Anyway, I would love to here your thoughts on the matter.
Thanks!
Current distributions use Gnome 3.32, but the extension from extensions.gnome.org only supports up to Gnome 3.26. If someone could publish an updated (stable) version, that would be great.
Thanks.
I see these in journalctl:
giu 26 13:40:47 archos org.gnome.Shell.desktop[1045]: Gjs-Message: JS WARNING: [/home/luca/.local/share/gnome-shell/extensions/audio-switcher@AndresCidoncha/extension.js 95]: assignment to undeclared variable defsource
giu 26 13:40:47 archos org.gnome.Shell.desktop[1045]: Gjs-Message: JS WARNING: [/home/luca/.local/share/gnome-shell/extensions/audio-switcher@AndresCidoncha/extension.js 90]: assignment to undeclared variable item
giu 26 13:40:47 archos org.gnome.Shell.desktop[1045]: Gjs-Message: JS WARNING: [/home/luca/.local/share/gnome-shell/extensions/audio-switcher@AndresCidoncha/extension.js 31]: assignment to undeclared variable defsink
giu 26 13:40:47 archos org.gnome.Shell.desktop[1045]: Gjs-Message: JS WARNING: [/home/luca/.local/share/gnome-shell/extensions/[email protected]/extension.js 44]: assignment to undeclared variable trayIconImplementations
Without the extension, the default behaviour on Ubuntu 20.04 (GNOME 3.36.1) is to only show the input audio volume slider when an input device is accessed by an application (e.g. recording audio). After installing this extension, the input audio volume slider is always shown (together with input device selection dropdown menu). It would be nice if the extension would also auto-hide the input audio slider/menu by default (and ideally offer a config option to always show if preferred).
Tryed to install from gnome extensions page on GS 3.32.0 and got error
I'm basically just pulling in anduchs/audio-output-switcher#5 since this seems to be the most active fork. Currently this extension doesn't show any audio devices for me, other than the default. gnome-control-center seems to parse audio devices differently, including what in pavucontrol are listed under Configuration / Profiles.
There was already an attempt to support this in the original ports2 branch that people claimed was working 5 years ago, if anyone feels adventurous!
https://github.com/anduchs/audio-output-switcher/compare/ports2
it would be great if this extension only showed the dropdown menu with the name of the current input and output devices if there was actually more than one to choose from. that way, the visual clutter is minimal when using my laptop as-is, while making it easy to switch to another input/output device when i plug into a dock or external microphone.
Gnome 3.34 is out since september, and we need support for it.
Could you please add gnome 3.34 support ?
I would love to learn what's needed to do so, but it seems that adding the version number to the json file is not enough.
Latest seems to be for 3.24.
My HDMI output is missing from the extension's dropdown, but is visible in system settings. Possibly related to #17.
It looks like the latest gnome-shell, version 3.34, breaks this extension.
I am using Arch Linux.
Can you publish a new version for Fedora 27?
Running on RHEL 8.3 with gnome-shell 3.32.2
The error in the logfile is:
Some code accessed the property 'ENABLED_EXTENSIONS_KEY' on the module 'extensionSystem'. That property was defined with 'let' or 'const' inside the module. This was previously supported, but is not correct according to the ES6 standard. Any symbols to be exported from a module must be defined with 'var'. The property access will work as previously for the time being, but please fix your code anyway.
Extension "audio-switcher@AndresCidoncha" had error: TypeError: GObject.registerClass() used with invalid base class (is PopupSubMenuMenuItem)
Gnome 40 is out in in Fedora 34, so users are starting to use it.
Thanks for the nice little extension, I use it daily.
Hi!
Great extension, I use it on a daily basis and find it a valuable addition to the Gnome desktop. Thank you for your work!
There is one little issue: After logging in, my USB headset is selected by the extension. However, sound is coming from my loudspeakers. Changing volume does not change the loudspeaker volume then.
Only after selecting my loudspeakers in the audio switcher menu, I can control their volume again.
Keep up the great work!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.