Interface management

When a snap needs to access a resource outside of its own confinement, it uses an interface. Interfaces enable resources from one snap to be shared with another.

Interfaces are commonly used to enable a snap to access OpenGL acceleration, 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.

Most users don’t need to worry about interfaces. Snaps are designed for strong application isolation and safe interface connections are made automatically.

To see which interfaces a snap is using, type snap interfaces <snapname>:

$ snap interfaces vlc
Slot                     Plug
:desktop                 ffmpeg,spotify,vlc
:home                    ffmpeg,spotify,vlc
:network                 ffmpeg,lxd,spotify,vlc
:opengl                  ffmpeg,spotify,vlc
:optical-drive           ffmpeg,vlc
:pulseaudio              ffmpeg,spotify,vlc
(...)

See Supported interfaces for a comprehensive list of interfaces supported by snap.

Slots and plugs

An interface consists of a connection between a slot and a plug. The slot is the provider of the interface while the plug is the consumer, and a slot can support multiple plug connections.

interfaces_plugs-slots

In the previous output (see above), the left column lists the slots that the VLC snap is using, while the right column lists the snaps plugged into the slots. FFmpeg, Spotify and VLC are all accessing the system-provided network interface slot, for example, giving them all network access.

Manual connections

An interface may be automatically connected when the snap is installed, or manually connected at some point after installation.

To list all currently registered interfaces, along with their slots, plugs and current connections, use the snap interfaces command with no further arguments:

$ snap interfaces
Slot                             Plug
:alsa                            -
:pulseaudio                      ffmpeg,spotify,vlc
-                                ffmpeg:alsa
(...)

Interfaces provided by the system begin with the : (colon) symbol and are implemented by the Core snap, such as with :alsa in the above output. For a slot to be visible, and connectable, its corresponding snap needs to be installed.

To view which snaps provide connectable slots and plugs, use the snap interface <interface name> command:

$ snap interface alsa
name:    alsa
summary: allows access to raw ALSA devices
plugs:
  - ffmpeg
slots:
  - core

To make a connection, use the following syntax:

$ snap connect <snap>:<plug interface> <snap>:<slot interface>

A slot and a plug can only be connected if they have the same interface name. For example, to connect FFmpeg’s ALSA plug to the system’s ALSA slot, you’d enter the following:

$ sudo snap connect ffmpeg:alsa :alsa

To disconnect an interface, use snap disconnect:

$ snap disconnect <snap>:<plug interface> <snap>:<slot interface>

Following our previous example, you could would disconnect ffmpeg:alsa with the following command:

$ sudo snap disconnect ffmpeg:alsa :alsa

A successful connection grants any necessary permissions that may be required by the interface to function.

Last updated 21 days ago. Help improve this document in the forum.