Interfaces are the means by which an installed snap gets access to system resources. Interfaces that are required for normal operation are specified at snap build-time within the app and service metadata of a snap’s snapcraft.yaml.
Many interfaces are automatically connected when a snap is installed. These include network, audio-playback and opengl, but this ability is dependent on the permissiveness of each particular interface.
Other interfaces require the user to make a manual connection, such as camera and removable-media. Once published in the Snap Store, automatic connections may be requested for these interfaces on a case-by-case basis.
For example, it may be reasonable for a photo-booth application to expect an automatic connection to the
camera interface. Those requests are submitted and processed in the open on the Snapcraft forum. For more details on this process, see Permission requests .
Interfaces are implemented as
slots. A plug in one snap may connect to a slot in another and this provides access to the resources required. For example the
ohmygiraffe snap specifies the
opengl plug which connects to the
opengl slot provided elsewhere - in this case by the
Users may view the interfaces used as a list of
slots via the
snap connections command:
$ snap connections ohmygiraffe Interface Plug Slot Notes network ohmygiraffe:network :network - network-bind ohmygiraffe:network-bind :network-bind - opengl ohmygiraffe:opengl :opengl - pulseaudio ohmygiraffe:pulseaudio :pulseaudio - x11 ohmygiraffe:x11 :x11 -
Developers specify a list of
plugs for each application inside a snap being exposed to the host OS. Each application may have a different set of
plugs specified. Developers should endeavour to list only the
plugs required for normal operation of the application.
In a simplified example, a snap which contains both a server, which connects to a webcam to stream online, and a graphical application, to view the camera, may have interfaces listed as follows:
apps: streamer: command: bin/streamer-cli plugs: - network-bind - camera frontend: command: bin/frontend-gui plugs: - network - camera - x11
The state of a connection can be checked within a snap using the snapctl utility. See Using the snapctl tool for further details.
When building a snap, its interfaces will be as unique as its application requirements. You can use the
snappy-debug tool to figure out which interfaces a snap needs.
The FFmpeg multimedia framework, for example, needs interfaces for audio, USB cameras, network access and the desktop, among many others. The game Spelunky needs to access OpenGL, the desktop environment and any connected joystick.
The process of adding interfaces requires the snap developer to have a good understanding of the applications it contains, but there are certain categories of snap that require the same, or very similar, sets of interfaces.
Being familiar with these can help to speed up snap development:
See Supported interfaces for the full list of interfaces available for snaps to use.
Last updated a month ago. Help improve this document in the forum.