Closed sergei-dyshel closed 6 years ago
First things first: Do you have dunst 1.1 or dunst 1.2? If 1.1, it might be good updating dunst to 1.2 (or current master). Between 1.1 and 1.2 several years development. It might be the case, that action handling might have been added or improved after 1.1.
Actual answer: There is no need to use the script
configuration for your use case. The notification standard has a term called "actions". This is exactly your use case what you want. Most messengers do this already natively. e.g.: Telegram provides some actions to dunst (with the default of opening the message). If I middle click the notification in dunst, I invoke the default action (actually there are plenty more configuration options). By this, dunst sends to the client (Telegram), that it should open itself with the current message.
I guess, you're on 1.1, so here what I'd do: Install dunst from source, read up the ACTIONS
part of the dunst
-manpage.
@bebehei, thank you for explanations! The problem is I already using version v1.2.0
(this exact Git tag) and tried using Actions but it didn't work for me. It's important to mention that I'm using Dunst with i3 window manager and I compare my experience to Gnome 3 with built-in notification server.
For example after I've enabled native notifications in Chrome, I'm getting the following notification on WhatsApp message (by using WhatsApp web interface web.whatsapp.com):
{
appname: ''
summary: 'Group'
body: 'web.whatsapp.com
+972 54-346-5555: Some message 😜'
icon: 'info'
raw_icon set: false
category:
timeout: 10
urgency: 1
formatted: '<b>Group</b>
web.whatsapp.com
+972 54-346-5555: Some message 😜'
fg: #ffffff
bg: #285577
frame: #aaaaaa
id: 3
actions:
{
[default,]
[settings,Settings]
]
script: (null)
}
There are two actions in this notification, and I suppose that the first one should focus Chrome tab with Whatsapp, and it does so in Gnome. When dmenu is presented I have a choice of two items: # []
and #Settings []
but neither of them works.
Another example is official Slack client for Linux, which is built as Electron app. The notification looks like:
{
appname: 'Electron'
summary: 'A Notification from Slack'
body: 'What do you know? It works.'
icon: '(null)'
raw_icon set: true
category:
timeout: 10
urgency: 1
formatted: '<b>A Notification from Slack</b>
What do you know? It works.'
fg: #ffffff
bg: #285577
frame: #aaaaaa
id: 6
actions:
{
[default,View]
]
script: (null)
}
Here I get only #View [Electron]
in dmenu but choosing it does nothing, while in Gnome clicking on the notification opens relevant conversation in Slack.
Unfortunately I don't know how to identify the exact problem so I welcome to any suggestions!
@sergei-dyshel Thanks for you thorough explanation. Although I avoided the dmenu part, I tested it today and it works very well.
and actions work perfectly like your expectation.
So: what does dbus-monitor path=/org/freedesktop/Notifications
log, when you invoke the action?
I've tried opening WA in Firefox and that's what dbus-monitor
shows (I choose the only action, default
):
method call time=1507042910.615039 sender=:1.201 -> destination=:1.36 serial=14 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=GetServerInformation
method call time=1507042910.615425 sender=:1.201 -> destination=:1.36 serial=15 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=GetCapabilities
method call time=1507042910.793711 sender=:1.201 -> destination=:1.36 serial=16 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
string "Firefox"
uint32 0
string ""
string "+972 52-564-0000"
string " 💃 - 18:01"
array [
string "default"
string "Activate"
]
array [
dict entry(
string "image-data"
variant struct {
int32 212
int32 212
int32 848
boolean true
int32 8
int32 4
array of bytes [
...
# a very long array of bytes
...
]
}
)
]
int32 -1
method call time=1507042915.810085 sender=:1.201 -> destination=:1.36 serial=17 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=CloseNotification
uint32 33
signal time=1507042915.810357 sender=:1.36 -> destination=:1.201 serial=136 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=NotificationClosed
uint32 33
uint32 3
signal time=1507042927.280028 sender=:1.36 -> destination=:1.201 serial=138 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=ActionInvoked
uint32 33
string "default"
signal time=1507042927.280028 sender=:1.36 -> destination=:1.201 serial=138 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=ActionInvoked uint32 33 string "default"
So, here: dunst does everything right. There has to be something wrong in the chain after dbus (dunst <--> dbus <--> ... <--> Browser <--> Whatsapp tab
).
Can it be related to the fact that I'm running i3 as GDB session (with gnome-settings-daemon
in the background), by using https://github.com/lvillani/i3-gnome/?
I'm not sure, but it may be the case. If you're using plain i3, does it behave correctly?
@bebehei I'll check this first thing when I have to exit session or reboot the laptop :smile:
method call time=1507042915.810085 sender=:1.201 -> destination=:1.36 serial=17 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=CloseNotification
uint32 33
signal time=1507042915.810357 sender=:1.36 -> destination=:1.201 serial=136 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=NotificationClosed
uint32 33
uint32 3
signal time=1507042927.280028 sender=:1.36 -> destination=:1.201 serial=138 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=ActionInvoked
uint32 33
string "default"
Looks like the client closed the notification(via a CloseNotification
signal) right before you invoked the action, it probably stopped listening/waiting for actions at that point.
Remember actions don't work after the notification has been closed
I'd guess the problem is here: org.gnome.SettingsDaemon.PrintNotifications
@bebehei
I'm using previous version of gnome, in which gnome-settings-daemon
is not split to many processes, so I have only RequiredComponents=gnome-settings-daemon
in that line.
AFAIU
script =
specified in rule will be executed immediately as soon the notification appears. Is there a way to execute some script only when I press some key or middle(/right)-click on the notification.For example I'd like to write a rule that when I receive a notification of new chat message from user XXX I want to have an ability to quickly open conversation with this user.