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

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

Open
FarrenHawk opened this issue Jan 2, 2025 · 2 comments · May be fixed by #637

Comments

@FarrenHawk
Copy link

When I open my laptop lid, I briefly see my desktop, and then hyprlock shows up. This is with a bone stock hypridle config (the code from the example hypridle config on the hyprland wiki), even worse, hyprlock isn't focused, so unless I move my mouse, I type in other applications.

I shouldn't have to state why this is an absolutely horrible security hole, but more importantly for me, it's just plain annoying.

here's my hypridle config:

general {
    lock_cmd = pidof hyprlock || hyprlock       # avoid starting multiple hyprlock instances.
    before_sleep_cmd = loginctl lock-session    # lock before suspend.
    after_sleep_cmd = hyprctl dispatch dpms on  # to avoid having to press a key twice to turn on the display.
}

listener {
    timeout = 150                                # 2.5min.
    on-timeout = brightnessctl -s set 10         # set monitor backlight to minimum, avoid 0 on OLED monitor.
    on-resume = brightnessctl -r                 # monitor backlight restore.
}

listener {
    timeout = 300                                 # 5min
    on-timeout = loginctl lock-session            # lock screen when timeout has passed
}

listener {
    timeout = 330                                 # 5.5min
    on-timeout = hyprctl dispatch dpms off        # screen off when timeout has passed
    on-resume = hyprctl dispatch dpms on          # screen on when activity is detected after timeout has fired.
}

listener {
    timeout = 1200                                # 20min
    on-timeout = systemctl suspend                # suspend pc
}

I've tried futzing around with the before_sleep_cmd in my hypridle config by changing it to activate hyprlock --immediate to no avail, as well as adding lines to my hyprland.conf that either run systemctl suspend or hyprlock --immediate on laptop lid close (and the latter of which I also tried on laptop lid open. But when I ran hyprlock on both lid close and lid open, hyprlock was frozen entirely)

Any help/advice? I really love hyprlock because of how damn good looking it is, I really want it to work.

@winkelnp
Copy link

winkelnp commented Jan 2, 2025

I also had this issue (this is a dupe of my issue #547) and use a workaroud with a systemd service that runs before sleep.target (inspired by https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Custom_systemd_units)
I'm not sure where this problem is caused, but this seems to fix it (for now):

/etc/systemd/system/[email protected]
-----
[Unit]
Description=User Suspend Actions
Before=sleep.target

[Service]
User=%i
Type=simple
Environment=XDG_RUNTIME_DIR="/run/user/$(id -u %i)"
ExecStart=/usr/bin/hyprlock # this fails and then hypridle starts hyprlock -- no clue why this works
ExecStartPost=/usr/bin/sleep 1

[Install]
WantedBy=sleep.target

activate with systemctl enable user-suspend@{your username}.service

It's a little temperamentful, sometimes this service can be disabled and it works fine, sometimes I get the issue you're describing. I haven't had the issue since adding this service though.

@FarrenHawk
Copy link
Author

Oh, that's awesome!! Glad I'm not the only one with this issue, seems to be a not insignificant issue. I'll try that!!

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 a pull request may close this issue.

2 participants