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

Support custom script execution on clicking on a notification #1369

Open
cmihail opened this issue Jul 24, 2024 · 1 comment
Open

Support custom script execution on clicking on a notification #1369

cmihail opened this issue Jul 24, 2024 · 1 comment
Labels
Milestone

Comments

@cmihail
Copy link

cmihail commented Jul 24, 2024

Issue description

I have a custom Waybar module that displays notifications count via dunstctl and on click it pops the latest notification from history. Whenever a new notification is received a custom script is executed to send a signal to Waybar to update the notification count.

But the problem is that dunst doesn't have any proper custom script execution on clicking on a notification (i.e. closing it). For normal notifications, I use the following code to send a signal to waybar for notifications whenever a notification is closed:

#!/bin/bash
dbus-monitor --profile "interface='org.freedesktop.Notifications'" | \
  awk '/NotificationClosed/ { system("$HOME/.config/waybar/scripts/update_notifications_signal.sh") }'

While this works for normal notifications, it doesn't work for notifications retrieved from history as those do not emit a DBUS event (see #1352).

Though I think that the proper solution here is not to finish #1352, but to be able to execute a custom script on clicking on a notification similarly to the following when receiving a notification:

[script_waybar_signal]
  summary = "*"
  script = $HOME/.config/waybar/scripts/update_notifications_signal.sh

Installation info

  • Version:
$ dunst -v
Dunst - A customizable and lightweight notification-daemon 1.11.0
  • Install type: package
  • Window manager / Desktop environment: Hyprland
  • Distro: Fedora 40
Minimal dunstrc
[global]
  follow = mouse
  origin = top-center
  idle_threshold = 10s
  mouse_left_click = "do_action, close_current"
  mouse_right_click = "close_current"
  mouse_middle_click = "close_all"
  icon_path = "/usr/share/icons/AdwaitaLegacy/48x48/legacy/"
  icon_theme = AdwaitaLegacy

[script_waybar_signal]
  summary = "*"
  script = $HOME/.config/waybar/scripts/update_notifications_signal.sh

[ignore_volume_change]
  stack_tag = "change_volume"
  history_ignore = yes
  timeout = 1s

[ignore_brightness_change]
  stack_tag = "change_brightness"
  history_ignore = yes
  timeout = 1s

[skip_google_meet_notifications]
  body = "*meet.google.com*"
  skip_display = yes
  history_ignore = yes

Note: I'd be interested in implementing this feature myself if that is fine.

@bynect
Copy link
Member

bynect commented Sep 26, 2024

Hello, sorry for the late reply. This is a great idea and probably will be added some time in the future.

Probably it could be accomplished by adding a run_script option to

mouse_[left/middle/right]_click (values: [none/do_action/close_current/close_all/context/context_all])

I'm not sure about how to specify the script though. Any suggestion is appreciated 👍🏻

@bynect bynect added the Feature label Oct 15, 2024
@bynect bynect added this to the v2.0 milestone Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants