Earphone remote in sound jack as X input

Those 'special' headphones or earphones which can be used on specialized devices to control media players, volume and mute usually have FOUR connections on the plug, versus the typical THREE a normal headphone output jack has.

The usual three are Left Channel, Right Channel and Ground (common), while the fourth is often set up as a multi-value resistance, each button when pressed presents a particular resistance on the fourth wire (+ ground), which the media device can sense and from that determine what function is needed. Pretty slick method of getting several buttons to work off one wire without resorting to expensive digital signal generators and stuff (all packed in that little blob on the wires!).

Four buttons might use four resistances (of any unit):

volume up:   1 ohm
volume down: 2 ohms
stop:        4 ohms
play:        8 ohms

If this looks suspiciously like a binary encoding scheme... it is!! (You're so smart!!) Using values similarly ratio'd, you can sense 16 different outputs, even handling multiple keys pressed at the same time. Taa Daa!

Old people might remember the first iPods, which had a little 4connector jack next to the audio out plug, which many devices plugged into alongside their audio plug which enabled control signals to be sent back and forth. This was phased out in favor of the (imho cooler!) fourth wire system... standard headphones will work as expected, and headphones set up to interface with the fourth wire method are accepted too.

But to answer your question (finally!!)... no, there is no 'standard' way to enable the functionality you're looking for. Bluetooth headsets would be your best solution. (mine are COOL!)


There is currently no standardized way to use your wired headset as input with Linux as far as i know. This means you won't be able to use your headset to control your music player - Bluetooth headsets on the other should work out of the box.


Not a solution for everyone, but my earphones are single buttoned. Apparently, some of those simple earphone buttons use a kind of mic signaling mechanism that checks if mic input is "high" (see this post and this post). Using audacity, I was able to verify that clicking the button generated a characterstic peak unachievable by speech (although I haven't tried screaming!). Looking around the internet, I came up with the following solution using sox's rec:

#!/usr/bin/sh

while true; do 
    rec -n stat trim 0 .5 2>&1 | awk '/^Maximum amplitude/ && $3 > 0.89' | grep -q 'M' && playerctl play-pause
done

playerctl is a program that controls media playback. The .5 in the code indicates the mic pol resolution. You can play around with this value if you want to implement double tapping. 0.89 indicates the threshold for the button being pushed. (mine is basically equal to 1 when pushed)