mako
mako copied to clipboard
Add an on-closed event
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
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.
Isn't the notification API already a dbus API?
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.
This sounds like something that would replace the current on-X config system
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.
See https://github.com/emersion/mako/pull/552 for an example of a D-Bus event approach, for modes.
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.
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
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