The snapctl command will soon grow a sub-command to query connection status of given plug or slot. This was requested for a long time (e.g. https://bugs.launchpad.net/snapd/+bug/1809708 and Bug #1809708 “Allow snaps to query interface connection status directly from snapd”) and for good reasons as finding out if a plug or slot of the snap is connected from within its hooks or apps was not easily possible and required workarounds (probing of effective permissions, or using interface hooks to track connections etc).
It was internally agreed that the syntax would be as follows:
snapctl is-connected <plug|slot>
Since snapctl is executed from hooks or from apps of a snap, snap name is implied by the running context and the plug or slot name is always referring to that snap. Moreover, since plug and slot names are unique within a snap, there is no ambiguity here.
The proposed semantics (to be confirmed) for the new command is to return zero (non-error) status if the plug or slot is connected, and error status otherwise.
CC @pedronis