I am trying to detect a signal when a headphone is connected or disconnected from the system. What is the best way to do this?
If there is a special board with drivers, that will be my preferred way.
Thank you for your time.
|
This information is available in Headphone connected:
Headphone disconnected (see
You could use inotify to check if the file was modified and grep the information. See also http://askubuntu.com/questions/133809/mute-sound-on-headphone-unplug. |
||||
|
|
|
Find the udev tagger of the jack on the System, connect a client (dbus-monitor) that monitors the bus using DBus for messages on jack connect & disconnections. |
|||
|
|
|
A tool called hda-verb can enable/disable the headphone jack using pins. For example, To enable headphone jack, use:
To disable headphone jack, use:
Since you just want to check its status, perhaps you can use some polling mechanism in your java program which can check the status of above pins using hda. For this, your java program should be able to call hda-verb. Alternatively, you can check the source of hda-verb as it is available and see how they have done it. Hope this helps. |
|||
|
|
/systhen, and perhaps notifications via dbus. – Gilles Dec 1 '11 at 15:30