Snapcraft interfaces

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 by the developer.

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 .

Plugs and slots

Interfaces are implemented as plugs and 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 core snap.

Users may view the interfaces used as a list of plugs and 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

Common interfaces

When building a snap, its interfaces will be as unique as its application requirements.

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.