Interfaces for users

interfaces · for users for users

How a snap's connections look from the command line, what snap connect and snap disconnect do, and how snapd remembers an automatic connection you removed.

On the map: the travellers' ward, inside the gatehouse

▶ Watch this deck — 4 scenes, ~3 min

01 Seeing the connections

FOR USERS $ snap connections photo-editorInterface Plug Slot Notescamera photo-editor:camera - -home photo-editor:home :home -network photo-editor:network :network -removable-media photo-editor:sdcard - - :home, :network: slots of the system ← not connected← not connected ← connected at install camera photo-editor:camera :camera manual← you connected it inside, the app only gets an error, such as permission denied
Terminal output of snap connections photo-editor: camera and sdcard (removable-media) not connected, home and network connected automatically; a manual note appears when you connect by hand; inside, the app only sees an error

snap connections photo-editor lists each plug, its slot and a note. A dash as the slot means not connected; manual means you connected it. An unconnected plug shows up inside the app only as an error.

You've installed the photo editor, and you'd like to know what it can reach. snap connections, with the snap's name, lists every plug it has: the interface, the plug, the slot it's connected to, and a note. A slot that starts with a colon belongs to the system. A dash in the slot column means not connected. Here that's the camera and removable-media. Home and network connected by themselves at install, so their note is a dash too. Connect something by hand and the note says manual. The app can't see any of this; it just gets an error, such as permission denied.

02 Connecting and disconnecting

CONNECT AND DISCONNECT $ sudo snap connect photo-editor:camera system :camerathe only camera slot permissions change: root, or polkit asks for your password photo-editoreditor: cameraconvert: no camera plugevery app that uses the camera plug gets the camera $ sudo snap disconnect photo-editor:camera $ snap changes... Done ... Connect photo-editor:camera to snapd:camera
sudo snap connect photo-editor:camera picks the system's camera slot; polkit can ask for a password instead of sudo; the connection applies to every app in the snap that uses the plug; snap disconnect removes it; both appear in snap changes

sudo snap connect photo-editor:camera connects the plug to the system's camera slot; snap disconnect photo-editor:camera removes it. Both act on the whole snap and show up in snap changes.

Now you'd like to take a picture with the webcam. Snap connect, naming the photo editor's camera plug, does it. You don't have to name a slot: snapd picks the system's only camera slot. Changing permissions needs root, so use sudo, or polkit asks for your password. The connection belongs to the whole snap, so every app in it that uses the camera plug gets the camera. Done with it? Snap disconnect, with the same plug, takes it away again. Both run as changes, so snap changes lists them afterwards.

03 What snapd remembers

WHAT SNAPD REMEMBERS $ sudo snap disconnect photo-editor:network connected at installthe next refresh? an automatic connectionkept on record: not wantedauto-connect skips it a connection you madesimply forgotten $ sudo snap connect photo-editor:networkback again $ sudo snap disconnect --forget photo-editor:networkthe record is dropped: the next refresh may connect it by itself
Disconnecting the automatically connected network plug keeps a record that auto-connect skips on the next refresh; a manual connection is simply forgotten; snap connect brings it back; snap disconnect --forget drops the record

Disconnecting an automatic connection is remembered across refreshes, so it stays disconnected. snap disconnect --forget drops that memory, and auto-connection may connect the plug again.

A week later you decide the photo editor shouldn't have the network. Snap disconnect removes it. But network connected by itself at install, so what stops the next refresh from connecting it again? snapd keeps that connection on record, marked as one you didn't want, and auto-connect skips it. A connection you made by hand is simply forgotten when you disconnect it. Changed your mind? Snap connect brings it back. And snap disconnect --forget drops the record too, so the next refresh connects the plug by itself again.

04 Where to go from here

ROADS Interfaces for users home · network AppArmor promptingasked before a file opens Interface familieswhat each interface allows The overlordwhat snap changes shows For developershow the plugs got there
Roads for users: home and network, AppArmor prompting, the interface families, the overlord and the developers' deck

Roads: home and network, AppArmor prompting, the interface families, the overlord, and the developers' deck.

Listing, connecting, disconnecting, and one thing snapd remembers. Here's where to go next. Home and network are the two interfaces you'll meet most, and each has a deck. If home feels like all or nothing, AppArmor prompting asks you before the app opens a file. The interface families list every interface and what it lets a snap do. The overlord explains the changes that snap changes shows. And the developers' deck shows how the plugs got there in the first place.

Read more

Commands

CommandEffect
snap connectionsconnected plugs and slots of all snaps
snap connections --allalso the unconnected ones
snap connections <snap>every plug and slot of that snap, connected or not
snap interface <interface>what the interface is for, and which snaps have plugs and slots of it
snap connect <snap>:<plug>connect to the one system slot of the plug's interface; fails if there are several
snap connect <snap>:<plug> <snap>connect to the one slot of that interface on the other snap
snap connect <snap>:<plug> <snap>:<slot>connect to that slot
snap disconnect <snap>:<plug>disconnect everything from that plug
snap disconnect <snap>:<plug> <snap>:<slot>disconnect that one connection
snap disconnect --forget <snap>:<plug>also drop the record that keeps an automatic connection from returning

snap connect and snap disconnect need root, a user logged in with snap login, or polkit authorisation (io.snapcraft.snapd.manage-interfaces). Listing needs nothing.

Reading snap connections

ColumnMeaning
Interfacethe interface name; for content, the content tag follows in brackets
Plug<snap>:<plug>, or - for an unconnected slot
Slot<snap>:<slot>; :<slot> for the system; - if the plug is not connected
Notesmanual if you connected it, gadget if the device's gadget did, - otherwise

What is remembered

You disconnectAfterwards
an automatic connectionit stays disconnected across refreshes; snap connect brings it back
a connection you madeforgotten; nothing reconnects it
either, with --forgetforgotten; an automatic connection may return at the next refresh

Further reading

Roads from here

INTERFACES AND CONFINEMENT

RUNNING SNAPS

INTERFACE FAMILIES · every interface, grouped by what it touches

DESKTOP · snaps in a user session