Skip to content
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

allow signaling a parent process that the screen was locked #637

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dkondor
Copy link

@dkondor dkondor commented Jan 3, 2025

(partially) fixes #633

Hi!
I've recently tried out hyprlock and it works nicely with my setup! (using Wayfire mostly) However, I also noticed the issue reported in #633 and I think it is mainly caused by not being able to delay suspend until the screen is locked.

This patch adds two (related) ways to signal to a parent process when the screen has been locked:

  1. Writing to an inherited file descriptor: after the screen has been locked, a single newline is written to the FD given as an argument to the -R / --ready-fd option. Similar functionality exists in swaylock.
  2. Creating a child process (with fork()) and waiting until it locks the screen (-D / --daemonize option). This ensures that when the parent process exits, the screen is locked. This is equivalent to the -fork-on-lock option in waylock or the -f / --daemonize option of swaylock.

Using the second option and e.g. swayidle, it can be ensured that the screen is locked before suspend:

swayidle -w before-sleep "hyprlock -D"

The first option can be tested e.g. with the screenlocker proxy service I'm working on:
https://github.com/dkondor/wayland-screenlock-proxy/tree/hyprlock

Caveats / TODO:

  • Not tested with hypridle yet (but likely would need the equivalent of the -w option in swayidle unless I'm missing something)
  • This only works well if no_fade_in = true is set in the config, since it signals success immediately when getting the locked event. I looked into how the fade-in animation is managed, and seems I would need to check when bga == 1 here, but I'm unsure how to get this information to the CHyprlock class yet.
  • Both options do not work well together (if both -D and -R is given, the latter is ignored); not sure if this should be an error, or the worked around to still signal the fd given to -R

@PaideiaDilemma
Copy link
Collaborator

PaideiaDilemma commented Jan 4, 2025

I think vaxry and me probably both thought about adding this.
Swaylock does that, but I thinks it is not an ideal solutions, since you still need to script it yourself.

Check out #609
I think we could handle this in hypridle by using such an approach.
Solving two issues at once.

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.

Desktop briefly flashes and gets focused before hyprlock is opened upon the system moving out of suspend
2 participants