Error trying to comunicate with Spotify via DBus

I’m trying to package my programs that tries to use DBus for retrieving the current song from Spotify. But when the connections is tried in the snap version I get an error from AppArmor:

AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.733" (uid=1000 pid=22081 comm="/snap/lyricfier/x22/bin/lyricfier " label="snap.lyricfier.lyricfier (complain)") interface="org.freedesktop.DBus.Properties" member="Get" error name="(unset)" requested_reply="0" destination="org.mpris.MediaPlayer2.spotify" (uid=1000 pid=16486 comm="/snap/spotify/36/usr/share/spotify/spotify " label="snap.spotify.spotify (enforce)")

My complete snapcraft.yaml looks as:

name: lyricfier
base: core18
version: '0.1'
summary: xxx
description: |

grade: devel
confinement: devmode

    plugin: go
    source: .
    source-type: git
      - gcc
    command: bin/lyricfier

I’ve already tried adding some “plugs” that were mentioned in the forum but always get the same message and the connections is prevented.

Can anyone hint me in the right direction?


AFAICT the spotify snap needs to expose a mpris slot, while your snap needs a similar plug. Once connected it should be able to use the media player interface from your confined snap.

It may well be the case that spotify does not have the right slot declared in the snap. I would suggest reaching out to spotify and asking them to add it. Seems like functionality that many folks would be interested in.

Thanks it worked!

I’ve declared the plug mpris and then I’ve manually connected the interface with:

sudo snap connect lyricfier:mpris spotify:spotify-mpris

I’ve added that recipe to installation readme for my users.

Yes, this is precisely how it is meant to work. Glad you found it! :slight_smile:

Doing some more tests. There is a problem in the snap version. I can read the song data from:


But lyricfier is not notified of changes using the matching singal: "org.freedesktop.DBus.Properties", "PropertiesChanged".

This only occurs in the snap version. Is not a big problem for me because I’ve changed to use a an interval timer for getting the metadata. Not sure if I need another perm or just a bug in snapd.


When this happens, do you see security policy denials in journalctl?

Yes, I’m seeing:

Feb 27 15:17:20 chulo-xps dbus-daemon[2298]: apparmor="DENIED" operation="dbus_signal" bus="session" path="/org/mpris/MediaPlayer2" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" mask="send" name="org.freedesktop.DBus" pid=11122 label="snap.spotify.spotify" peer_pid=21011 peer_label="snap.lyricfier.lyricfier"

Thanks. That is a bug in the mpris interface. I’ve taken a todo to adjust this in the next round of policy updates.

Thanks to you for the help and clarifications. Let me know if I can help with testing.

Last question: Is possible to do an auto connection for lyricfier and spotify?

I’ve already asked in this topic:

But not sure if I’ve asked correctly because I didn’t receive any response.

Thanks again.

It was added to the reviewers queue, but yes, it deserves a response. We can move this part of the conversation over there.

Another thing to report. I was trying to use snapctl to get the status of the connection.

Listing connections shows a “manual” connection:

~ $ sudo snap connections lyricfier
Interface                 Plug                       Slot                             Notes
mpris                     lyricfier:mpris            spotify:spotify-mpris            manual

Running snapctl:

$ snap run --shell lyricfier
To run a command as administrator (user "root"), use "sudo <command>".

$ snapctl is-connected mpris
$ echo $?
0 # ok expected
$ snapctl is-connected spotify:spotify-mpris
$ echo $?
1 # not connected?
$ snapctl is-connected lyricfier:mpris
$ echo $?
1 # not connected?

That looks correct to me. Your second and third examples are trying to assert a specific combination of interface connections. All you can discern from within a snap is whether an interface is connected, not to where it is connected.

1 Like

Oh ok. If I understand there is no way to know if snap is correctly connected to spotify using snapctl :sweat:. I was looking for a way to warn my users to run the correct command. thanks.

1 Like