0

I have two audio output channels:

  • internal speaker
  • headset

I would like to switch between both via a key on the keyboard.

There are some special keys above the number block which I don't use. For example there is a key which opens a calculator.

How could I get this done?

guettli
  • 2,932
  • 12
  • 67
  • 115
  • 1
    creating a script that changes the output channel and then bind it to key press may work. This may help https://askubuntu.com/a/14083/1112104 or you can use some gnome-extensions like https://extensions.gnome.org/extension/906/sound-output-device-chooser/ – Parag Katoch May 29 '21 at 17:30
  • 1
    Does this answer your question? [Shortcut to switch between Analog Stereo output & HDMI audio output](https://askubuntu.com/questions/41858/shortcut-to-switch-between-analog-stereo-output-hdmi-audio-output) – Pablo Bianchi Jul 08 '21 at 21:21

2 Answers2

1

I created a script which changes the audio-sink in a round-robin fashion:

https://github.com/guettli/change-audio-sink/blob/main/change-audio-sink.py

You can map this script to a key with your desktop environment.

guettli
  • 2,932
  • 12
  • 67
  • 115
0

As said, on Settings → Keyboard shortcuts you can create a custom one to a command similar to:

bash -c '[[ $(pacmd list-cards | grep "active profile" | cut -d " " -f 3-) = "<output:hdmi-stereo-extra1+input:analog-stereo>" ]] && pacmd set-card-profile 0 "output:analog-stereo+input:analog-stereo" || pacmd set-card-profile 0 "output:hdmi-stereo-extra1+input:analog-stereo"'

Of course you should change the card profiles accordingly of those between you want to toggle.

screenshot

See also.

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117