Gnome 3 shell snaps integration

Ubuntu 17.04

How to integrate snaps into gnome 3 shell application menu bar and menu?

It looks like snaps applications are not recognized by gnome 3 shell. We can make them favorite and add them on the application bar.

Exemple: blender snap

are you using a wayland session ? there was a fix for this in:

No, it is on 17.04, and 17.10, with proprietary nvidia-driver (so, no wayland).

tested on wayland too, it is the same.

what does “snap version” show ? (it is definitely supposed to work (and AFAIK also does work for most))

There was an issue in gnome-shell with matching desktop files with running applications that broke the icon and application menu for running applications from snaps. This was fixed in gnome-shell 3.26 but not backported to older releases.

snap version
snap 2.28.5+17.10
snapd 2.28.5+17.10
series 16
ubuntu 17.10
kernel 4.13.0-16-generic

gnome-shell --version
GNOME Shell 3.26.1

I am using ubuntu 18.04 and still have broken icons and no ability to add the app I am running to the list of favorites.

My set-up is the following:

$ snap version
snap    2.32.8+18.04
snapd   2.32.8+18.04
series  16
ubuntu  18.04
kernel  4.15.0-22-generic
$ gnome-shell --version
GNOME Shell 3.28.1
$ snap list       
Name   Version    Rev   Tracking  Developer  Notes
core   16-2.32.8  4650  stable    canonical  core
slack  3.1.1      6     stable    slack      classic

At the moment, I have to press Meta + r and execute snap run slack to start slack.

I want to press meta and start typing slack to start the application.

This is working for me (not tested with slack, but confirmed with other snaps).
Does slack install a desktop file under /var/lib/snapd/desktop/applications/ ?
Does XDG_DATA_DIRS include /var/lib/snapd/desktop ?

$ lh /var/lib/snapd/desktop/applications 
total 8,0K
-rw-r--r-- 1 root root  57 Mai 28 10:17 mimeinfo.cache
-rwxr-xr-x 1 root root 355 Mai 22 12:53 slack_slack.desktop
$ echo "$XDG_DATA_DIRS"

In /etc/profile.d/ is the following snippet:

 8 # desktop files (used by desktop environments within both X11 and Wayland) are
 9 # looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for
10 # snappy applications' desktop files.
11 if [ "${XDG_DATA_DIRS#*/snapd/desktop}" = "${XDG_DATA_DIRS}" ]; then
12     export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share:/usr/share}:/var/lib/snapd/desktop"
13 fi

My default shell is zsh but this should not cause gnome-shell to fail executing this script, or not?

note that for Xorg (and gnome-shell under Xorg) the var is set in /etc/X11/Xsession.d/65snappy (not sure where the Wayland equivalent lives)

Not sure this is entirely true. Here on Arch, XDG_DATA_DIRS is set in /etc/profile.d/ and looking up snap applications from Gnome overview works just fine. I would expect Ubuntu setup to nearly identical.

this only applies to pam based shell logins, no ?

in ubuntu 16.04 i definitely have:

$ dpkg -S /etc/X11/Xsession.d/65snappy 
snapd: /etc/X11/Xsession.d/65snappy
$ dpkg -l snapd|grep ^ii
ii  snapd     amd64        Daemon and tooling that enable snap packages
$ snap version
snap    2.32.8
snapd   2.32.8
series  16
ubuntu  16.04
kernel  4.13.0-39-generic

and /etc/X11/Xsession.d/65snappy contains:

$ cat /etc/X11/Xsession.d/65snappy 
# This file is sourced by Xsession(5), not executed.
# Add the additional snappy desktop path

if [ -z "$XDG_DATA_DIRS" ]; then
    # 60x11-common_xdg_path does not always set XDG_DATA_DIRS
    # so we ensure we have sensible defaults here (LP: #1575014)
    # as a workaround

(it might indeed be that Arch simply sources profile.d even for graphical logins or some such)

zsh doesn’t source /etc/profile (and thus files in /etc/profile.d/) by default. It does source /etc/zsh/zprofile, but that one doesn’t appear to do anything by default.

@ehj can you copy the contents of /etc/profile.d/ in $HOME/.zprofile, restart your session and see if that “fixes” the issue?

copy the contents of /etc/profile.d/ in $HOME/.zprofile, restart your session

These instructions brought up a slack icon when search for slack in the overview and the context menu when right clicking over the running app icon (which is the correct icon now) offers the correct options.
So, the problem is “solved”.

What would be the best way for a long lasting solution?

I guess snapd could be made zsh-aware, i.e. it could install a script similar to /etc/profile.d/ in a place that zsh will source. You could file a bug to make sure this gets acknowledged as a feature request by the development team.

The feature request is filed as a bug at launchpad!

FYI, the content of /etc/zsh/zprofile on Arch is:

$ cat /etc/zsh/zprofile  
emulate sh -c 'source /etc/profile'

which would explain why /etc/profile[.d] stuff ends up being loaded in zsh here too. Looking at the PKGBUILD, the file is not shipped by the source tarball but rather comes as part of the packaging. Wondering if other distros do the same.

Note there is about zsh (with comments from one of the debian zsh maintainers)