-
-
Notifications
You must be signed in to change notification settings - Fork 67
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? |
src/core/DBusManager.cpp
Outdated
} | ||
|
||
std::shared_ptr<sdbus::IConnection> DBusManager::getConnection() { | ||
std::lock_guard<std::mutex> lock(m_mutex); |
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.
this lock does nothing cause it passes its raw resource out of the function, same below. outer std::shared_pointer
is thread safe. about inner check https://github.com/Kistler-Group/sdbus-cpp/blob/master/docs/using-sdbus-c++.md#thread-safety-in-sdbus-c
I should be fine but it says it is generally better to create exclusive proxies for different threads.
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.
Got it, thanks for the feedback!
I removed the locks (b22009f), and since our usage is pretty low-volume I don't think we really need multiple threads at the moment.
If you have any other comments, let me know
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.
Right we don't even use the proxies in different threads.
In that case can you use SP<>
(shared pointer impl from hyprutils) instead of std::shared_ptr
?
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. |
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