DIY detection of plug connection
simulate this circuit &ndash; Schematic created using CircuitLab

Without knowing how much current you are switching, this idea is diagrammatic - adjust resistor values to suit your needs and use a suitable switch element.

The principle is simple - if there is a short before connection, the Sense line will be at Gnd, if not it will be at Vcc/2. (Of course, once the switch closes Sense will be at Vcc, which may need protection of your sensing circuit.) Once the connection is made, Sense will drop to some lower value; this is how you detect the connection.