How to automatically change volume level when un-/plugging headphones?
- by htorque
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.