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.
|show 2 more comments|
This information is available in
Headphone disconnected (see
You could use inotify to check if the file was modified and grep the information.
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.
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.