Linux is cool, I can do a lot of things with it. If i set a config file in Linux, I am damn sure that it is ran every single time. The code does what you tell it to do.

There is 1 thing that always seems to be “black magic”: 1) lid close and suspend 2) lid close and suspend and lock.

If we ignore locking for a moment and focus on suspend. I cant seem to figure out why sometimes lid close would suspend immediately, when other time it takes 5 seconds after lid closes. On some days, lid closes would not even suspend !!

Did anyone manage to get suspend work 100 %? I cant believe we have tons of great linux tools and years into kernel dev, and still suspend is a hit or miss.

  • Atemu@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    4 hours ago

    In Hyprland, how it works is that you define the screen lock command (e.g. swaylock) in hypridle and that gets wired into logind somehow such that you can loginctl lock-session.

    I then (also in hypridle) define a before sleep hook that locks the session.

    I believe the proper way to do this would be to run your lockscreen as a systemd unit that is WantedBy and Before suspend.target. This would in theory take care of making it idempotent and reliably show the lockscreen before initiating suspend.
    A friend of mine has this sort of setup and, while it is reliable, the lockscreen is still racy and sometimes only triggers after suspend. Might be the lockscreen unit not signalling its readiness to systemd properly though.