这是indexloc提供的服务,不要输入任何密码
Skip to content

Add an on-closed event #578

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Queuecumber
Copy link
Contributor

@Queuecumber Queuecumber commented Apr 1, 2025

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

…osed/dismissed.

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
@emersion
Copy link
Owner

emersion commented Apr 1, 2025

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.

@Queuecumber
Copy link
Contributor Author

Isn't the notification API already a dbus API?

@emersion
Copy link
Owner

emersion commented Apr 1, 2025

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.

@Queuecumber
Copy link
Contributor Author

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

@emersion
Copy link
Owner

emersion commented Apr 1, 2025

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
Copy link
Owner

emersion commented Apr 1, 2025

See #552 for an example of a D-Bus event approach, for modes.

@Queuecumber
Copy link
Contributor Author

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
Copy link
Contributor Author

Queuecumber commented Apr 1, 2025

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
Copy link
Contributor Author

Queuecumber commented Apr 2, 2025

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

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

Successfully merging this pull request may close these issues.

2 participants