Dunst: Action on click on notification ?

Created on 12 Apr 2014  路  9Comments  路  Source: dunst-project/dunst

Hi,

I'm using dunst as a notification daemon on my system, and I'm using it in particular to display Thunderbird notifications (thanks to the Gnome Integration addon).

Is there any way to change the click action ? I'd like to be able to focus Thunderbird when I click on the notification.

Thanks

Most helpful comment

For anyone that has landed here via search, this is very possible through simple scripting via dunstify.

When using --action, dunstify will either return the action name you specify or a number. The number adheres to the Notification spec, so if 1 is returned, the notification expired and if 2 is returned then the notification was dismissed by the user.

So just handle the result:

reply_action () {}
forward_action () {}
handle_dismiss () {}

ACTION=$(dunstify --action="default,Reply" --action="forwardAction,Forward" "Message Received")

case "$ACTION" in
"default")
    reply_action
    ;;
"forwardAction")
    forward_action
    ;;
"2")
    handle_dismiss
    ;;
esac

See Arch Wiki for more information.

All 9 comments

Probably for posterity: press ctrl+shift+period.

I'm new and had the same question so I started searching. It says here that the context menu can be used to invoke this action. And it looks like the default keyboard shortcut for that is the aforementioned _ctrl+shift+period_. So there you go.

EDIT: In case you knew that but also wanted to be able to do that with the mouse, I'm afraid I will be of no help.

@deiwin wow, thanks for this, I totally forgot about it.

I tried the shortcut but, as expected, it does not work out of the box. If I understood correctly, I have to manually bind an action to the notifications. Do you have doc about this as well?

Thanks!

You can find information about the configuration here: https://github.com/knopwob/dunst#configuration

The variable you're looking for should be under [shortcuts] and should be called context. Here's what the relevant parts of my config look like:

[shortcuts]

    # Other shortcuts

    # Context menu.
    context = ctrl+shift+period

Thanks!

For anyone that has landed here via search, this is very possible through simple scripting via dunstify.

When using --action, dunstify will either return the action name you specify or a number. The number adheres to the Notification spec, so if 1 is returned, the notification expired and if 2 is returned then the notification was dismissed by the user.

So just handle the result:

reply_action () {}
forward_action () {}
handle_dismiss () {}

ACTION=$(dunstify --action="default,Reply" --action="forwardAction,Forward" "Message Received")

case "$ACTION" in
"default")
    reply_action
    ;;
"forwardAction")
    forward_action
    ;;
"2")
    handle_dismiss
    ;;
esac

See Arch Wiki for more information.

Thanks the addition!

You can also use do_action (bound to middle click by default, can be changed to either left or right in the config) paired with an action named default which will avoid showing dmenu.

@tsipinakis That's even better! Then you can differentiate when a shortcut dismisses the notification and when the notification is left-clicked. Thank you.

Here's how to customize mouse actions in dunstrc. I've updated the Arch Wiki to articulate these possibilities.

@brettinternet thank you!

I landed here because I wanted to click in my notification and execute the action. On the left, if there is an 'A' on the notification it means there is an action attached and if there's an 'U' it means there is an URL. To execute the action with the mouse, you can do it with a middle click.

Reference

Was this page helpful?
0 / 5 - 0 ratings

Related issues

existme picture existme  路  4Comments

phuhl picture phuhl  路  3Comments

chronus7 picture chronus7  路  5Comments

bebehei picture bebehei  路  4Comments

Anachron picture Anachron  路  4Comments