Keywords: bash, KDE 4, kmix, select Master Channel, automatic
Depends on: kmix
Like nearly all laptops, I have a built-in MIC and speakers. When I skype, I prefer to use my wireless USB headset.
KDE provides global shortcuts which allow you to bind your keyboard's volume up/down/mute keys. In turn, the requests are handed to kmix. kmix dutifully obeys the commands but only for the currently selected Master Channel (in kmix, see Settings > Select Master Channel ...).
What I wanted is kmix to automagically set the master channel to my headset when plugged in and when it's not, revert back to the integrated device.
I asked on IRC, checked Google but came up empty. I wrote a simple shell script which starts at KDE login to monitor when I plug in my headset. When it detects it's been plugged in, it uses qdbus to instruct kmix to switch its master channel.
The script has set up instructions.
The script cites the following excellent URL which enabled me to write the qdbus call: http://usrlocalbin.blogspot.ca/2008/04/qdbus-tutorial-part-one.html
With my wireless headset, the above script switches the master channel when the USB clip is connected. The headset does not have to be turned on. This might be a slight annoyance to people. :)
If this becomes a problem, I'll see if there's an additional Linux status provided when the USB clip makes contact to the headset.