Unable to use mpris interface

I have made a snap based on the yaml below. It’s a command line spotify music application which uses mpris to show up in the various desktop integration points.

The binary when run outside snap works as expected, and registers via mpris so I can change tracks. I can see it register the correct name under dfeet.

However, when snapped, it does this:

  snap "ncspot" has bad plugs or slots: ncspot-mpris (invalid name element: "org.mpris.MediaPlayer2.ncspot")

What am I doing wrong?

name: ncspot
base: core18
version: '0.1.2'
summary: Cross-platform ncurses Spotify client written in Rust
description: |
  ncurses Spotify client written in Rust using librespot. It is heavily 
  inspired by ncurses MPD clients, such as ncmpc. My motivation was to 
  provide a simple and resource friendly alternative to the official 
  client as well as to support platforms that currently don't have a 
  Spotify client, such as the *BSDs.

grade: stable
confinement: strict

apps:
  ncspot:
    environment:
      LD_LIBRARY_PATH: "$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio:$LD_LIBRARY_PATH"
      LC_ALL: "C.UTF-8"
    command: ncspot
    plugs:
      - network
      - network-bind
      - audio-playback
      - config-ncspot
    slots:
      - ncspot-mpris

slots:
  ncspot-mpris:
    interface: mpris
    name: org.mpris.MediaPlayer2.ncspot

plugs:
  config-ncspot:
    interface: personal-files
    write:
    - $HOME/.config/ncspot

parts:
  ncspot:
    plugin: rust
    source: https://github.com/hrkfdn/ncspot.git
    source-tag: $SNAPCRAFT_PROJECT_VERSION
    build-packages:
      - libasound2-dev
      - libncurses-dev
      - libncursesw5-dev
      - libssl-dev
      - libdbus-1-dev
      - pkg-config
      - libpulse-dev
      - libxcb1-dev
      - libxcb-render0-dev
      - libxcb-shape0-dev
      - libxcb-xfixes0-dev
    stage-packages:
      - libpulse0
      - libncursesw5
      - libasound2
      - libdbus-1-3
      - libgcc1
      - libgcrypt20
      - libgpg-error0
      - liblz4-1
      - liblzma5
      - libssl1.1
      - libsystemd0
      - libtinfo5
      - libxcb-render0
      - libxcb-shape0
      - libxcb-xfixes0

Thanks to some super help from @Wimpress This turned out to just be a matter of adding the unity7 plug. Once done, mpris started working. Sorry for the noise.

See The mpris interface

in the mpris case “name” should be just the last component, so “ncspot” in this case

I tried that too, that doesn’t work. I had to specify unity7. Specifying combinations of desktop and x11 didn’t work, only adding unity7 did.

@jdstrand do we have some kind of bug in this area? looking at the code for sure we use

org.mpris.MediaPlayer2.###MPRIS_NAME###{,.*}

in the apparmor profile

Sorry, my mistake - I iterated on this a LOT last night. It does work with the mpris name ncspot, but only if I also use unity7. Here’s the yaml that works.