Snapctl is-connected plug|slot

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. 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


Related PR is now up:

1 Like

This feature has landed and should become available with snapd 2.43.


Note - that since this is only in 2.43, if as a developer you make use of this, you should add an assumes: 2.43 to your snapcraft.yaml as per Interfaces for Raspberry Pi imager