Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I like to switch the sound output from Speaker to USB headphone with a Shortcut. Is there a way to accomplish this?

share|improve this question
    
Closely related: askubuntu.com/questions/41858/… –  Takkat Jun 28 '12 at 6:16

2 Answers 2

up vote 1 down vote accepted
  • Check for port names pactl list sinks (I remove non needed sinks output):

    Sink #1
        State: RUNNING
        Name: alsa_output.pci-0000_00_1b.0.analog-stereo
        Description: Built-in Audio Analog Stereo
        Driver: module-alsa-card.c
    ...
        Ports:
            analog-output-speaker: Speakers (priority: 10000, not available)
            analog-output-headphones: Headphones (priority: 9000, available)
        Active Port: analog-output-headphones
        Formats:
            pcm
    
  • Set sink port using pactl set-sink-port:

     pactl set-sink-port 1 analog-output-speaker
    

    or

     pactl set-sink-port 1 analog-output-headphones
    

    If you are using USB device its better to use sink name instead of id, Example:

     pactl set-sink-port alsa_output.pci-0000_00_1b.0.analog-stereo analog-output-headphones
    

Ref: man pactl

share|improve this answer
    
Thank you. Finally after a long time a working answer :) –  rechengehirn Feb 15 at 19:55
    
Come'n :) you were still waiting, I just fill it in case someone need it come by. –  Sneetsher Feb 15 at 20:00
    
Really. I haven't found a solution for that. But i stopped trying to find one a long time ago. –  rechengehirn Feb 15 at 20:04

Do this in 2 steps:

  1. Find a command line setting to change back/forth between these settings.

  2. Add these to some key combinations. Systems Settings >> Keyboard >> Shortcuts

share|improve this answer
    
How can one find out, what command line setting is needed to switch the sound output? Is there a way to trace what happens, when I do it with the GUI? –  rechengehirn Jun 28 '12 at 5:43
    
No, you need to use amixer (command line) and/or alsamixer (char-mode) in a terminal. These are old-school, and require some effort to master. Start by adding output from amixer -c 0 to your question .. –  david6 Jun 28 '12 at 7:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.