mako icon indicating copy to clipboard operation
mako copied to clipboard

Add an on-closed event

Open Queuecumber opened this issue 7 months ago • 9 comments
trafficstars

In some cases (for example, informing an external monitor like waybar) it can be useful to peform an action when a notification is closed/dismissed. This PR adds a on-closed event to allow mako users to take such an action.

For example, to signal waybar to reload its state, the user could add:

on-closed=exec pkill -SIGRTMIN+5 waybar

See #550 for more details

Queuecumber avatar Apr 01 '25 17:04 Queuecumber

I don't think users should configure mako to reload the state of indicators such as waybar. Instead, I think mako should provide APIs to allow indicators to subscribe to state changes, e.g. with a D-Bus event.

emersion avatar Apr 01 '25 18:04 emersion

Isn't the notification API already a dbus API?

Queuecumber avatar Apr 01 '25 18:04 Queuecumber

mako has two D-Bus APIs: the standard D-Bus one for applications submitting notifications, and a mako-specific one for makoctl and other tools. We already expose the current list of notifications there. We could add an event fired when a notification is added or dismissed.

emersion avatar Apr 01 '25 18:04 emersion

This sounds like something that would replace the current on-X config system

Queuecumber avatar Apr 01 '25 18:04 Queuecumber

No: on-X is meant to be used by users, while D-Bus events are meant to be used by other tools interacting with mako.

emersion avatar Apr 01 '25 18:04 emersion

See https://github.com/emersion/mako/pull/552 for an example of a D-Bus event approach, for modes.

emersion avatar Apr 01 '25 18:04 emersion

I'm not sure I understand the distinction, at least not in this case.

Certainly if I was developing an application that depended on Mako then listening for DBus notifications is the way to go, it's a more efficient and cleaner design.

But that isn't whats happening with Waybar, it doesn't have first-class support for any notification system so you have to configure it to call scripts which interrogate Mako (or whatever you are using), and your options are either poll or use unix signals to coordinate the state updates.

Maybe there is a way to do that with DBus using a continuously running loop that sits on the bus and waits for notifications then emits JSON (I think this is supported by Waybar? Maybe worth a shot...) but either way I am approaching this as a user, at least for now.

Also I don't necessarily want to derail this too much with discussions about Waybar, I think the on-dismissed notification could be useful for other things and it feels more like feature parity with the on-notify event. The fact that it unblocks some bar users is incidental.

Queuecumber avatar Apr 01 '25 18:04 Queuecumber

Let me also look at #552 and see if there's a similarly easy way to add a DBus event for notify and dismiss since I'm poking around anyway

Queuecumber avatar Apr 01 '25 18:04 Queuecumber

Please see #579

This also turned out to be relatively simple including the Waybar integration (which I will follow up on in #550)

That PR may supersede this one or compliment it depending on your preference

Queuecumber avatar Apr 02 '25 01:04 Queuecumber