-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
Add D-Bus signals to notify session lock and unlock states #609
base: main
Are you sure you want to change the base?
Conversation
While i understand what you want to achieve, i think that is not the way this dbus interface is supposed to work. From org.freedesktop.login1:
So from what i understand |
Yes, I agree it’s a bit unclear, but from what I understand, Unlock() is intended to inform the Session Manager and other programs listening to D-Bus that the lock screen should be removed. It’s up to each listening process to handle this notification as they see fit. In this case, Hyprlock directly manages the unlock process via Wayland using the ext_session_lock_v1 interface. In other scenarios, a lock screen might call Unlock() to signal the Session Manager that the unlock should proceed after successful authentication. The key point is that Unlock() does not handle the unlocking itself—it simply notifies that it should occur or has occurred. By sending the Unlock() method after handling the unlock, Hyprlock ensures compatibility with tools and listeners on D-Bus, even if it doesn’t rely on them. Since Hyprlock already performs the actual unlock via Wayland, calling Unlock() is purely informational and has no functional impact on the unlocking process. |
Can't you just use smth like |
But i agree that it would be better if hypridle's unlock_cmd just worked... |
Yes, but we should map every hyprlock call or make an alias.
I'm looking into it, there's not much documentation or code about it out there. I see GDM calls login1.Manager UnlockSession() method that uses Session Unlock. GDM
|
i3-lock and swaylock lack the functionality. But I found there's a Also, I found a comment with an interesting interpretation of the org.freedesktop.login1 documentation and how it could be properly implemented. With Gnome-Shell and GDM it would be something like:
Translated will be similar to this path:
Another solution would be to have a configuration option for a unlock_cmd in Hyprlock, so we can set |
The only thing is that we now would have 2 dbus connection objects for org.freedesktop.login1, when a user enables fingerprint authentication as well. We should centralize that by implementing a dbus manager class. Idk if you would want to try to do that. If you don't , I think we can do it afterwards. Also it would be good to add an option to enable/disable this. Enable per default. |
I centralized the dbus connection, could you give it a look please? |
I am still a bit unsure if this is the right solution. For me it is unclear if it is appropriate to call this method as a session-lock client. What i also did not consider initially is that
to have However signaling lock/unlock is also related to the start before suspend problem that we also have. If we can properly signal lock and unlock, we can solve that by waiting for locked in before_sleep_cmd. What do you think about just implementing an internal way of signaling lock/unlock to hypridle and use that for two additional triggers in hypridle and to wait for locked when launching hyprlock via before_sleep_cmd. |
Yeah, also though about the compositor handling it at first, but it seems like a simpler solution to just do it here. And yes, I think there should be no problem if it is set twice.
That's a bit confusing. unlock_cmd would never be called because no one (hyprlock/hyprland) tells hypridle that it unlocked / not send dbus signal. But yeah, when it does it will be redundant.
I like the idea of an internal unlock signal. However, I still see value in keeping the D-Bus signals for broader compatibility, but not a big problem. I'm not sure if there's already, and if there is how, a channel used by Hyprland and Hypridle or hypr apps in general to communicate between them, could you point me to? I think there is, just not very familiar with. |
I think that is a really good idea! Have Hyprland signal to hypridle whether we are locked or not.
Well the existing channel is wayland. I don't think there is anything else that we could use for that purpose. We would need an internal protocol for that. It could work exactly like the idle-notify protocol. As a wayland client we can request to be notified and then we will receive a |
What do you think about this idea? We are trying to solve the "lock before suspend problem" as well as giving hyprIDLE the ability to launch commands when we unlock. swaylock has
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also in dire need of a clang-format
|
||
class DBusManager { | ||
public: | ||
static DBusManager& getInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's not how we do singletons in hyprland.
inline std::unique_ptr<CDBusManager> g_pDBusManager;
public: | ||
static DBusManager& getInstance(); | ||
|
||
std::shared_ptr<sdbus::IConnection> getConnection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SP?
#include <string> | ||
#include <sdbus-c++/sdbus-c++.h> | ||
|
||
class DBusManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CDBusManager
const auto fingerprintAuth = g_pAuth->getImpl(AUTH_IMPL_FINGERPRINT); | ||
const auto dbusConn = (fingerprintAuth) ? ((CFingerprint*)fingerprintAuth.get())->getConnection() : nullptr; | ||
if (fingerprintAuth){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no {}
@Iamanaws vaxry misunderstood me and reviewed the pr instead of the comment, but he has nothing against such a protocol. I will make one in hyprland-protocols and start a hyprland implementation : ) |
@Iamanaws I created hyprwm/hyprland-protocols#12 and hyprwm/Hyprland#9092 You wanna do the hypridle impl, or should i? |
@PaideiaDilemma go for it, you're half the way |
Send an "Unlock" D-Bus signal to notify programs listening for Unlock events.
This enables tools like hypridle to detect the Unlock event and execute the unlock_cmd.
Issues:
hyprwm/hypridle#79
hyprwm/hypridle#112