Open ryanabx opened 8 months ago
It is currently planned, but not implemented. I could review your PR if you wanted to work on it, but I recommend doing it in pieces.
org.freedesktop.Notifications.ActionInvoked
and org.freedesktop.Notifications.ActivationToken
from https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html are going to be required for performing the action. I assume when the notifications cards are pressed, the default action is performed.
It might be easier to implement this in the notifications daemon first. https://github.com/pop-os/cosmic-notifications. On pressing a button, the notifications daemon could request an activation token using cosmic::applet::token::subscription::activation_token_subscription
, though, if it's going to be used in the notifications daemon, maybe it should be separate from the applet feature. And after receiving the token, it can emit the previous signals.
The notifications daemon and the applets are going to need to coordinate on this to work in the applets. The applets would require similar steps, but need to use the dbus protocol defined by the notifications daemon to indicate that an action was performed. This would involve adding a method to the daemon's protocol that can be called by applets.
I'm looking at both cosmic-notifications and cosmic-applets trying to wrap my head around what's going on.
So the idea would be in cosmic-notifications to support org.freedesktop.Notifications.ActionInvoked
and org.freedesktop.Notifications.ActivationToken
, then make dbus interfaces for cosmic-applets to call org.freedesktop.Notifications.ActionInvoked
? Where does the ActivationToken come in? Are both sent to the client at the same time?
Here is a function in cosmic-notifications for action_invoked
, how does this function work, or is it just a stub?
https://github.com/pop-os/cosmic-notifications/blob/19f147f9ed8c46196bf6f5b5debc99a7228555fc/src/subscriptions/notifications.rs#L396-L401
There's also this function for ActivationToken. Is this a different ActivationToken? I notice it's a common function in the other applets as well https://github.com/pop-os/cosmic-applets/blob/d2922460321aa0788e5bce5f79294b50b304d199/cosmic-applet-notifications/src/main.rs#L334-L342
So the idea would be in cosmic-notifications to support org.freedesktop.Notifications.ActionInvoked and org.freedesktop.Notifications.ActivationToken
Yes, while cosmic-notifications does currently "support" the signals, it doesn't actually emit them and there is no button to activate the notification in the daemon.
org.freedesktop.Notifications.ActionInvoked and org.freedesktop.Notifications.ActivationToken from https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html are going to be required for performing the action. I assume when the notifications cards are pressed, the default action is performed.
https://github.com/pop-os/cosmic-notifications/blob/19f147f9ed8c46196bf6f5b5debc99a7228555fc/src/subscriptions/notifications.rs#L397 is where the action invoked signal is defined using the zbus
crate. It is actually a macro, so you can't see the method, but it exists. https://github.com/pop-os/cosmic-notifications/blob/19f147f9ed8c46196bf6f5b5debc99a7228555fc/src/subscriptions/notifications.rs#L160 might be helpful for you to look at as a reference of how to emit the signal. You'd need to add a new Input
variant like Input::ActionInvoked
and handle it there.
And then, there is already a Message
variant that can be given to the button and handled similarly to Message::Dismissed
https://github.com/pop-os/cosmic-notifications/blob/19f147f9ed8c46196bf6f5b5debc99a7228555fc/src/app.rs#L64 .
There's also this function for ActivationToken. Is this a different ActivationToken? I notice it's a common function in the other applets as well
Ya, this is the same activation token you will be using, but you will be using it a bit differently. The notification applet is currently passing it as an environment variable when it opens the settings application, but a token can also be sent over dbus. The signal will need to be added, but it should just be a few lines, and it can be added just below the action_invoked signal.
This is probably planned already, but notification bubbles, when clicked, should bring you to the app that pushed the notification, and then close the bubble.
I might want to try my hand at implementing this myself (I'd like to learn rust and at the same time contribute to COSMIC) but only if someone is not currently working on it.