This question already has an answer here:

I'm looking for something like presence of a file or its content that could indicate the headphone's presence. I am working on if statement on conky with condition being presence/absence of headphone/earphone.

marked as duplicate by don_crissti, Michael Durrant, chaos, G-Man, Eric Renouf Oct 31 '15 at 14:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.