Snapcraft daemon are not able to send notifications in Ubuntu

I prepared a tiny application for Ubuntu based on the Golang. This application checks memory usage every N seconds, and if memory usage highest of M%, try to send a notification every K seconds.
This is a pretty straightforward implementation, but when I install that snap - notifications do not appear. When I run that command manually - it’s works awesome.
That application uses the notify-send CLI tool to send the notification.

That my snapcraft.yaml:

    name: low-ram-detector
    base: core18
    version: '0.1'
    summary: Monitoring of RAM and swap
    description: |
      That app monitor RAW and swap, and send notifications if RAM or swap too low.

    grade: stable
    confinement: strict

        plugin: go
        source: .
          - build-essential
          - gcc
          - clang
          - libnotify-bin
          - CGO_ENABLED: "1"

          LOW_RAM_DETECTOR_VERBOSE: "true"
        command: bin/low_ram_detector
        daemon: simple
          - desktop

Does anyone know how to fix it?

daemons are not permitted to send desktop notifications to your user session. This is not something that an interface is able to fix. You’ll need to run the app in your user session for it to be able to send you notifications.

I believe they could use the user daemon feature for this, no? I can’t seem to find the example from @jamesh for how this is enabled/used.

1 Like

If user daemons are supported now, then yes, that will work. I hadn’t seen that they’ve arrived yet so I guess I’m behind the times ;-p

Yes. A user daemon would be able to handle this. Support for user daemons is still gated behind a feature flag at the moment though. I detailed how you can test the feature out in this thread:

1 Like