Interfaces allow (or deny) access to a resource outside of a snap’s confinement.
Most users don’t need to worry about interfaces. Snaps are designed for strong application isolation and safe interface connections are made automatically.
An interface is most commonly used to enable a snap to access sound playback or recording, your network, and your $HOME directory. But which interfaces a snap requires, and provides, is very much dependent on the type of snap and its own requirements.
See Supported interfaces for a comprehensive list of interfaces and what kind of access they permit.
Plugs and slots
An interface provides a level of access to resources, such as audio playback, as defined by a slot. One or more snaps can access this resource by connecting a corresponding plug to the slot.
In other words, the slot is the provider of the resource while the plug is the consumer, and a slot can support multiple plug connections.
In the output to snap connections vlc (see above), every interface used by VLC is listed in the first column. The Plug and Slot columns then describe how each interface is connected.
For instance, the audio-playback interface connects VLC’s audio-playback plug to the system’s audio-playback slot so you can hear the sound it produces.
You can see which snaps are using an interface with the interface command:
Many interfaces are automatically connected when a snap is installed, and this ability is a property of either the interface itself, or the snap.
Automatically connecting interfaces include the network, audio-playback and opengl interfaces. This auto-connection ability is carefully reviewed for each interface, where permissiveness, security and privacy implications, and the expectations of the user, are all considered.
A snap’s developer can also request that an interface is connected automatically through a manual review process. As above, these requests are carefully considered and reviewed before being granted or denied.
Interfaces not connected automatically require the user to make a manual connection (see below), such as the camera, removable-media and audio-record interfaces. Manual connections enable the user to have a complete control over what kind of access they allow.
If a snap is installed prior to an interface being granted auto-connect permission, and permission is subsequently granted and the snap updated, when the installed snap updates, the interface will be auto-connected.
A slot and a plug can only be connected if they have the same interface name.
Add the --no-wait option to snap connect or snap disconnect to run the process in the background and return immediately to the command prompt.
A successful connection grants any necessary permissions that may be required by the interface to function.
To disconnect an interface, use snap disconnect:
snap disconnect <snap>:<plug interface>
Following our previous example, you would disconnect vlc:audio-record with the following command:
sudo snap disconnect vlc:audio-record
Forget manual disconnections
When an automatic connection (see above) is manually disconnected, its disconnected state is retained after a snap refresh. This state is even stored after a snap has been removed, including removal with the --purge option.
The --forget flag can be added to the disconnect command to reset this behaviour, and consequently, re-enable the automatic re-connection after a snap refresh.