We can create a notification using simple commands.
ex:notify-send 'SUPER IMPORTANT!' 'This is an urgent message!' -u critical
Can we make it clickable and run a script while clicking on it? Like
When we click on a notification send by Nautilus file manager like this one
It directly opens a new window. But our custom notification doesn't do anything. How to make our custom notification do an activity when we click it.
Interesting question!
...Which was the trigger for the exploration below on the subject on the UB experimental repo. The result is a notification/message popup which has the following options:
Example of a notification with (optional) click-functionality
The first four options only apply if you set the argument, the corner defaults to bottom-right (on primary), unless set differently.
The life length is -as it is- hardcoded, defaults to 10 seconds, unless set differently.
Notes
dbus
, so they cannot be "listened" to. Further development could be to make it a daemon-like background process -keeping the Gtk loop alive-, only calling the window on dbus hint.How to setup
alternotify.py
, make it executableRun it with any combination of the following options, just pick what you need:
command="command_to_run"
title="Title to show"
body="Text body of the notification message, text, text, text"
icon="icon-name"
position=1
A complete command could look like:
The code