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, pulseaudio 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:

    command: bin/streamer-cli
      - network-bind
      - camera
    command: bin/frontend-gui
      - network
      - camera
      - x11

See Supported interfaces for the full list of interfaces available for snaps to use.

Snapcraft build, debug and publishing docs roadmap (page breakdown)
Creating snapcraft.yaml