pacmd list-cards seems to show
analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: yes)
when the headphones are plugged in, and
analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: no)
when unplugged.
pacmd list-cards
seems to showanalog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: yes)
when the headphones are plugged in, andanalog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: no)
when unplugged.Applies to Debian 9 ( Stretch )
Maybe this? https://unix.stackexchange.com/questions/25776/detecting-headphone-connection-disconnection-in-linux