How to automatically change volume level when un-/plugging headphones?

Posted by htorque on Ask Ubuntu See other posts from Ask Ubuntu or by htorque
Published on 2011-01-27T12:16:41Z Indexed on 2011/02/01 23:34 UTC
Read the original article Hit count: 330

Filed under:
|
|

What I want is the following:

  • When I plug in my headphones, I want the sound to be un-muted and set to a specific volume level.
  • When I unplug my headphones, I want the sound to be muted (or set to a specific volume level).

Setting the volume levels isn't the problem, but I somehow need to do this when un-/plugging the headphones, so I'm looking for a way to get notified of those events.

I quickly found /proc/asound/card0/codec#0 to indicate whether headphones are plugged in or not, so I tried to monitor it using inotifywait and change the volume level based on modified notifications. Unfortunately inotifywait failed because proc isn't an ordinary filesystem.

Are there other ways to do this (maybe via PulseAudio)?

Audio device: Intel HDA, audio codec: Conexant CX20585.

© Ask Ubuntu or respective owner

Related posts about audio

Related posts about pulseaudio