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.
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.
In my linux (Debian GNU/Linux 3.12.0 x86_64) this is know by acpi system so calling
this seems to depend of a selected option in the kernel config
If this is your case you can populate
Check acpid man page http://linux.die.net/man/8/acpid