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.