4

Like many of you, I'm getting the annoying notification that there's a pending update of snap-store:

Pending update of "snap-store" snap

Close the app to avoid disruptions (13 days left)

There are plenty of suggestions at that question as to how to make the notification go away, but it will happen all over again once there's a new update to snap-store.

Question

How can I prevent snap-store from automatically starting when I log in without uninstalling it?

Cause of the problem

As best as I can tell, the reason snap-store starts automatically is because the current version has an autostart file located at ~/snap/snap-store/current/.config/autostart/ubuntu-software-service.desktop

~/snap/snap-store/current is just a symlink that points to the currently installed version of snap-store:

ls -ld ~/snap/snap-store/current
lrwxrwxrwx 1 user user 3 Sep 28 08:43 /home/user/snap/snap-store/current -> 599

I'm not sure when the autostart file was added, but I can see as of version 41.3-66-gfe1e32544+ (revision 582), the file wasn't there:

ls ~/snap/snap-store/582/.config/autostart
ls: cannot access '/home/user/snap/snap-store/582/.config/autostart': No such file or directory

And it is there in revision 592:

$ ls ~/snap/snap-store/*/.config/autostart
/home/user/snap/snap-store/592/.config/autostart:
ubuntu-software-service.desktop

What I've tried

  • This answer suggests that to prevent a snap from starting at boot, the service needs to be disabled. But there's no service for snap-store.

  • The normal way to prevent an application from automatically starting is to create a custom autostart file, which should take precedence over the system one. So that's what I did:

    $ cat ~/.config/autostart/ubuntu-software-service.desktop 
    [Desktop Entry]
    Name=Ubuntu Software
    Exec=snap-store.ubuntu-software --gapplication-service %U
    OnlyShowIn=GNOME;Unity;
    # Disable autostart
    Hidden=true
    

    Unfortunately, it doesn't work.

  • I tried creating a script in /etc/profile.d/ to kill snap-store, but it runs before logging in, before snap-store has started

Current workaround

cat ~/.config/autostart/stop-snap-store.desktop
[Desktop Entry]
Type=Application
Name=Stop Ubuntu Software
Exec=snap-store --quit
X-GNOME-Autostart-Delay=30
OnlyShowIn=GNOME;Unity;
NoDisplay=True

Or to make the change for all users, put stop-snap-store.desktop in /etc/xdg/autostart/

bmaupin
  • 5,371

2 Answers2

2

You're so close!

Snap autostarts are not in ~/.config/autostart/
They are located in ~/snap/<application>/current/.config/autostart/
(reference)

Let's take a look at the autostart for snap-store:

$ ls -lah ~/snap/snap-store/current/.config/autostart/
lrwxrwxrwx 1 me me   66 Nov 26 08:24 ubuntu-software-service.desktop -> /snap/snap-store/current/autostart/ubuntu-software-service.desktop

Autostart is a link to a file in /snap. We cannot edit that file (files in /snap are read-only)
But you can remove (or restore) the link.

REMOVE:  $ rm ~/snap/snap-store/current/.config/autostart/ubuntu-software-service.desktop
RESTORE: $ ln -s /snap/snap-store/current/autostart/ubuntu-software-service.desktop ~/snap/snap-store/current/.config/autostart/

Snapd will regenerate the link then next time that snap updates, so it's not a permanent solution. The immutability, self-repair, and frequent updates are key features of snaps. Folks have been wanting those features on Ubuntu for years.

Fundamentally, autostart in snaps is developer-configurable, and that those developer definitions limit user configurations (again, that's a long-desired feature of snaps).

user535733
  • 68,493
0

I never found a better solution apart from the workaround I mentioned in my question.

However, it appears starting with Ubuntu 23.10 that the old snap-store app has been replaced by App Center.

Thankfully App Center is not configured to automatically start. So ultimately the "fix" for this problem is to upgrade to a newer version of Ubuntu.

bmaupin
  • 5,371