I'm using Ubuntu Lucid (10.04). In my shell script running as root I want to detect whether an audio cable (analog jack) is connected to the laptop or not. How do I do that? I don't need a portable solution, I need something, no matter how hacky, that works on my laptop.
One way could perhaps be to use
Jack plugged in:
Jack not plugged in:
So for that specific one I could do:
giving output of
One can also use commands and specify by
Get list by:
I came across a piece of software once, believe it used Tcl/Tk, that displayed pin-power for all ports on the computer + lots of other HW information. It was a nice piece of software – but I can't find it again. I have looked trough 12 old HDD's with no luck. I used it to debug some jack-ports. So yes, it is definitively possible to poll status of a specific port.
Jack is a pain to search the web for due to JACK. It makes it close to impossible.
I have some C-code that do some Soundcard information polling. Have to look if I can find it.
Since you said "no matter how hacky" . . .
Get an external sound card that you can connect to your laptop via USB. Plug the analog jack into that. Plug in your external sound card when you want to connect the audio jack and have your bash script detect whether or not the external sound card is connected via USB.