Sending desktop notifications from a snap

%E5%9C%96%E7%89%87

There are some circumstances where sending notifications from a snap be useful, like:

  • Informing the users that a cold launch take some time
  • Sending snap deprecation/obsoletion notice
  • Sending info about snap’s security confinement

This can be implemented in a launcher, by:

  • Adding libnotify-bin package to a part’s stage-packages
  • Connecting the snap to the desktop interface, which allows access to the Notifications D-Bus service
  • Calling notify-send ("${SNAP}/usr/bin/notify-send for classic confinement snaps) command in the launcher script

You may check out a demonstration snap here:

Do classic snaps not get automatic updates the same as all other snaps?

Non-classic snaps get automatic updates automatically (unless Canonical, Ltd. change their mind of not providing a switch to turn that feature off)

But where does it say specifically that classic snaps don’t get automatic updates? My understanding was that all snaps, regardless of confinement got automatic updates

Classic snaps do auto-refresh. Devmode snaps do not. There is a situation where going from strict to classic (iirc) that the snap won’t auto-refresh to classic (@popey may have more details).

1 Like

+1. Classic snaps refresh. Snaps which migrate from strict to classic do not autorefresh along the way. The user must remove and install the snap (with --classic) to opt into having an unconfined app which was previously confined.

Devmode snaps do not auto refresh. They can be force-refreshed.

1 Like

@jdstrand @popey Thanks for the correction, I must have mistaken it with the devmode snaps.

1 Like

@admins Please set this topic as a wiki, thanks in advance!

I’ve just done this. I’ll hunt around for other topics that might not be wiki-enabled, and enable them. :slight_smile:

1 Like

Just installed this snap on two different system. No notifications showed on either of them when it was run on the command line. No errors but also no notifications. Looks like something changed in the last two years and broke this demo notification snap.