You are not logged in.

#1 2014-05-12 13:18:42

nashod
Member
Registered: 2012-03-23
Posts: 39

Running a script on headphone detection

So I have a laptop running arch and I tend to plug and unplug my headphones on a rather frequent basis, my problem is that I want the built-in speaker to mute on headphone plug-in and the headphone channel to unmute, then on headphone unplug I want the headphone channel to mute and speaker chanel to unmute.

I have searched the internet and the wiki without success, I tried running udevadm monitor in hope of seeing what the plugin event was so I could at least have a starting point but it produced nothing.

Does anyone have anytips or solutions? It should be a fairly simple script/command to write but I have no idea where to even look.

Thanks in advance,
Nashod.

Offline

#2 2014-05-12 13:23:55

phw
Member
Registered: 2013-05-27
Posts: 318

Re: Running a script on headphone detection

If you are using Pulse Audio and it is a USB or bluetooth headset it can be configured to automatically switch to newly connected devices, see https://wiki.archlinux.org/index.php/Pu … SB_headset

Otherwise I can imagine you will be able to do this with a udev rule, especially if it is a USB

Not sure if any of the above will work if you plugin a headphone into the analog jack, though.

Offline

#3 2014-05-12 13:35:51

nashod
Member
Registered: 2012-03-23
Posts: 39

Re: Running a script on headphone detection

phw wrote:

If you are using Pulse Audio and it is a USB or bluetooth headset it can be configured to automatically switch to newly connected devices, see https://wiki.archlinux.org/index.php/Pu … SB_headset

Otherwise I can imagine you will be able to do this with a udev rule, especially if it is a USB

Not sure if any of the above will work if you plugin a headphone into the analog jack, though.

thanks for the help but it's alsa with an analog jack, my main problem is that I can't figure out what the udev event is as the udevadm monitor command does not show any events on plugin/plugout of the headphones

Offline

#4 2014-05-19 16:14:17

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Running a script on headphone detection

Does anything change in the /proc/asound/ tree when un/plugged? If you use a hda compliant sound card: I would argue you have to periodically read the status of certain registers with hda-verb. What codec is the sound card using? Check its datasheet for more information.

Offline

Board footer

Powered by FluxBB