Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action on click on notification ? #163

Closed
Phyks opened this issue Apr 11, 2014 · 13 comments
Closed

Action on click on notification ? #163

Phyks opened this issue Apr 11, 2014 · 13 comments

Comments

@Phyks
Copy link

Phyks commented Apr 11, 2014

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

@deiwin
Copy link

deiwin commented Jan 22, 2015

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.

@Phyks
Copy link
Author

Phyks commented Jan 22, 2015

@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!

@deiwin
Copy link

deiwin commented Jan 22, 2015

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

@Phyks
Copy link
Author

Phyks commented Jan 22, 2015

Thanks!

@Phyks Phyks closed this as completed Jan 22, 2015
@brettinternet
Copy link

brettinternet commented Jan 10, 2020

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.

@tsipinakis
Copy link
Member

tsipinakis commented Jan 10, 2020

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.

@brettinternet
Copy link

brettinternet commented Jan 10, 2020

@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.

@ensismoebius
Copy link

@brettinternet thank you!

@antoniovillavicencio
Copy link

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

@mark2185
Copy link

Is there a way to set a keyboard mapping for dunstctl action through the dunstrc?

I tried action = mod1+grave, but nothing happens. Calling dunstctl action works, tho.

@fwsmit
Copy link
Member

fwsmit commented Sep 22, 2021

No this is deliberately removed. You can set a shortcut through your DE/WM

@mark2185
Copy link

No this is deliberately removed. You can set a shortcut through your DE/WM

That's what I had as a workaround, thanks!

@daki456
Copy link

daki456 commented Aug 23, 2024

Can someone from here explain how can i run my script when i do left click on my mouse to run my script switch_to_workspace (swtiches to my 4 workspace where my vesktop is) because i can't seem to find the workaround. I was only able to make it work when notification pops up, not on left click. here is my config:

`[global]
monitor = 0
width = (0, 500)
height = 100
notification_limit = 0
origin = top-right
offset = 17x17
progress_bar = true
progress_bar_max_width = 500
progress_bar_corner_radius = 0
font = "Noto"
corner_radius = 10
frame_width = 2
mouse_left_click = do_action, close_current
mouse_middle_click = close_current
mouse_right_click = context
transparency = 85
background = "#0e4763"
foreground = "#99CCE5FF"
highlight = "AAE2FFFF"
frame_color = "3D7A99FF"
separator_color = frame
format = "%s\n%b"
icon_corner_radius = rider.val.rounding
timeout = 3
show_indicators = no

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants