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.

Ubuntu annoyingly switches the device for audio input and output from my USB headset to the built-in sound card every time I log out, hibernate, or shut down my computer. This takes place even though "USB Headset Analog Stereo" has the "Set as fallback option" selected in PulseAudio.

I decided to run a script every time my computer starts or thaws. Getting the commands to run when I log in is easy: I just put them in my .zshrc file. But I'm having trouble getting them to run when waking from hibernation. Here it is my script, which I put in /etc/pm/sleep.d:

#!/bin/bash

case "$1" in
    thaw|resume)
        pacmd set-default-sink "alsa_output.usb-Sennheiser_Communications_Sennheiser_USB_Headset-00-Headset.analog-stereo"
        pacmd set-default-source "alsa_output.usb-Sennheiser_Communications_Sennheiser_USB_Headset-00-Headset.analog-stereo.monitor"
        ;;
esac

The problem is that it doesn't execute the pacmd commands when thawing (I don't suspend my computer because it freezes when it resumes). I've tried numerous variations on the script, including putting the pacmd commands outside the case statement so that they (it would seem) execute regardless, but to no avail.

When I put other commands (such as gvim) in the script and hibernate and thaw my computer, they don't execute either. The commands do execute, however, if they are outside the statement and I run the script at the command line. If I put the commands in a script in /etc/pm/power.d outside a case statement, they execute twice.

share|improve this question
    
Suggesting another approach worth to try out: see if pacmd load-module module-switch-on-connect makes PA load your USB device correctly. –  Takkat Mar 1 '13 at 8:54

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.