Snap app is failing in Dbus and lagging some features

I build the snap of an app, that has a feature to open external player like-vlc; How can I make it work in snap?

The snapcraft.yaml file is

name: freetube # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: '0.18.0' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
compression: lzo

architectures:
  - build-on: amd64
  
slots:
  dbus:
    interface: dbus
    bus: session
    name: io.freetubeapp.FreeTube  
plugs:
  read-player:
    interface: system-files
    read:
      - /usr/bin

parts:
  freetube:
    source: https://github.com/FreeTubeApp/FreeTube/releases/download/v${SNAPCRAFT_PROJECT_VERSION}-beta/freetube_${SNAPCRAFT_PROJECT_VERSION}_amd64.deb
    source-type: deb
    # See 'snapcraft plugins'
    plugin: dump
    source-checksum: sha256/3ffaaa6b7883c55fa0da5a726e0249389cca435cb37b4af192262158bed0baa8
    override-pull: |
      snapcraftctl pull
      sed -i 's|Icon=freetube|Icon=usr/share/icons/hicolor/scalable/apps/freetube.svg|g' usr/share/applications/freetube.desktop
apps:
  freetube:
    command: opt/FreeTube/freetube
    common-id: io.freetubeapp.FreeTube
    extensions: [gnome]
    desktop: usr/share/applications/freetube.desktop
    environment:
      GTK_USE_PORTAL: 1
    plugs:
      - home
      - network
      - read-player

Also while executing I get this error,

Error org.freedesktop.DBus.Error.Failed: cannot find desktop file "/var/lib/snapd/desktop/applications/freetube_FreeTube.desktop"

Anyone point out what’s the problem?

@ogra Okay so replying you from the original thread. This is an youtube client app, and this has an feature called “Play in external player”. If I ship vlc with this snap, and the user had already have vlc installed, what should be done then? How should I link them? Also, the xdg-open command, I guess, that needs to be coded into the programme first, but I don’t think that’s done there.

The simple answer is you can’t.

A strict snap cannot call external programs explicitly. It can pass files or URI’s to the XDG portals, and the portals handle them as they will, which is usually by offering a selection of applications that match the MIME. After chosing the same answer several times, the portal may stop asking and simply open the app it remembers.

There is no way to force VLC to open aside from shipping VLC with your snap. If you pass the portal a file, whether directly via DBus or indirectly via the xdg-open wrapper in the base snap, you have no say in what app decides to consume it.

If your user then also has VLC installed on the host, from a packaging perspective, that’s no different to your snap, because it’s blind to the hosts VLC anyway.

There is no equivilent to flatpak-spawn in snap.

1 Like

Okay, but what about the dbus error?

It’s ambiguous. I wouldn’t expect you to actually need a .desktop file to use DBus, whether you were sending or receiving, so presumably the exact function being called might be demanding it rather than DBus generally. You can use the tool dbus-monitor to log the bug and tell what’s going on under the hood.

First step would be to validate, is there actually the file there, or not; as the error suggests?

ls /var/lib/snapd/desktop/applications

I always do my desktop icons via snap/gui folders, rather than desktop entry, so I can’t tell from just looking whether the above file would actually produce a proper .desktop file.

Sorry, I forgot to mention, there is a file in that folder, but the file name is freetube_freetube.desktop. I have no idea why so.

Complete guess, but if you replace lowercase the f and t in the string above, does the .desktop file name change along with it?

The error message seems to be implying the issue is case sensitivity, and this could be where the case is coming from.

The thing is, this common id is set by the app, developer. Hope it’ll not affect that. But there are other snaps, that don’t have this issue.

From what I’m aware, the ID is based on reverse DNS notation, and uppercase is not valid in DNS, so by a standards compliance perspective, the lowercase form is the correct case anyway. Whether this practically makes any difference, I guess we’ll find out!

Any given snap will generate hundreds of warnings and errors somewhere as a result of the sandboxing. Plenty of them are harmless in the end.

Okay, I am compiling it now

No… getting same error yet.

@soumyaDghosh Will you please transfer the snap name to me ?, i have recently been maintaining this and also has received upstream acknowledgement, it would have been good if you transfer this snap name to me ??, or i will need the upstream ping snap reviewers transfer this snap name to me.

I had earlier requested this name but received negative response from the reviewer, its redundant to publish upstream acknowledged snaps in redundant ways like freetube-snap etc. So kindly consider transferring this snap name to me.

I don’t have the name.

you didnt register ?? , i will request on behalf of the upstream to snap devs then.