Notifications from command line

What is the recommended way, from CLI or shell script or cron/timer command to:

  • show a notification

I have figured this out from an TJC thread.
notificationtool -o add --application=MyApp --urgency=2 --icon=icon-s-filled-warning "$title" "$body"
works fine.

But this only places a notification in the notification area. It does not show a popup and it does not trigger a sound. So how do I:

  • show a popup notification
  • trigger a sound

As said I would like to do this without coding an actual application in QML or whatever. Just simple scripting (python is okay if necessary).

Thanks for any pointers!!


Some related threads:

1 Like

The trick is to add a couple of extra ‘hints’ to the call. So if you do this:

notificationtool -o add --application=MyApp --urgency=2 --icon=icon-s-filled-warning "title" "body" --hint="x-nemo-preview-summary Popup summary" --hint="x-nemo-preview-body Popup body text"

you should get the popup as well. If you want to do it without having to install the lipstick-qt5-tools package, you can also call the dbus interface directly (I’m pretty sure gdbus is installed by default). Admittedly a bit more cumbersome, but fine if it’s going in a script.

gdbus call --session --dest org.freedesktop.Notifications --object-path /org/freedesktop/Notifications --method org.freedesktop.Notifications.Notify MyApp 42 "icon-s-filled-warning" "Summary" "Body" "[]" "{'x-nemo-preview-summary':<'Popup summary'>, 'x-nemo-preview-body':<'Popup body text'>}" 0

Incidentally, in case it’s helpful for future reference, apart from the sailfish-specific parts I got this example from man gdbus.

I’m not sure about sound/vibration though.


Thinking more about the sound, you could probably use something like this to play a sound at the same time. The paplay call blocks, so probably you’d want to trigger the notification first.

paplay /usr/share/sounds/jolla-ringtones/stereo/jolla-messagetone.ogg

There’s probably a better way to do this, but maybe it’ll be enough.


Thank you very much, the preview/popup works perfectly.

In fact, you don’t need hints really, notificationtool uses the last two parameters as popup title and content:

notificationtool <options> title text popuptitle popuptext

Vibration started to appear as well.


I compiled and ran this tool here successfully on SFOS 3.3

1 Like