Laptop lid behavior suspend/hibernate -> Locks screen #102

Closed
opened 2026-05-26 12:13:48 +02:00 by AramJonghu · 4 comments
Collaborator

With the current implementation, the only way the lock screen appears:

  • Manual input
  • Idle timers

There is no option to have it check for coming out of suspend/hibernate in general. Is this possible?

A C++ plugin can handle lid behavior. Then qml can pick this up.

  • Create plugin to listen to logind/elogind for lid behavior (closing or not).
  • Integrate into QML settings.
  • Add a settingswindow toggle to switch on or off lidwatch.
  • Have the default detect laptop battery or no battery to determine default behavior.
  • Test lidswitch enabled and disabled.
    • Must lock session before suspend occurs.
    • lidswitch disabled does not inhibit lock.
With the current implementation, the only way the lock screen appears: - Manual input - Idle timers There is no option to have it check for coming out of suspend/hibernate in general. Is this possible? A C++ plugin can handle lid behavior. Then qml can pick this up. - [x] Create plugin to listen to logind/elogind for lid behavior (closing or not). - [x] Integrate into QML settings. - [x] Add a settingswindow toggle to switch on or off lidwatch. - [x] Have the default detect laptop battery or no battery to determine default behavior. - [x] Test lidswitch enabled and disabled. - Must lock session before suspend occurs. - lidswitch disabled does not inhibit lock.
zach was assigned by AramJonghu 2026-05-26 12:13:48 +02:00
AramJonghu added this to the Zshell board project 2026-05-26 12:13:48 +02:00
AramJonghu added the bugquestion labels 2026-05-26 12:14:05 +02:00
Owner

I honestly don't know if that's possible directly from QML. If you can find a way then I'll gladly implement it, but the reason we have the lock() IPC call is so that you can lock it whenever you want it to lock, meaning you can set up whatever your equivalent of a systemd service with a trigger is to call the lock method.

I honestly don't know if that's possible directly from QML. If you can find a way then I'll gladly implement it, but the reason we have the `lock()` IPC call is so that you can lock it whenever you want it to lock, meaning you can set up whatever your equivalent of a systemd service with a trigger is to call the lock method.
Author
Collaborator

I did some digging. I have two main options.

  • Write a script on my system(s) to call lock when out of suspend/hibernate.
  • Write it myself into this project. This could be used for systemd, elogind (so no systemd), or anything else.

I like to write it myself if that is ok. It was suggested to write cpp, but my preference would be zig. I'd write a package like zshell-elogind-lock/ or similar. Would you be okay with zig in the project? In the end, it would be a binary that we'd end up using. What is your preference?

Edit: Python is another option indeed in our current codebase.

I did some digging. I have two main options. - Write a script on my system(s) to call lock when out of suspend/hibernate. - Write it myself into this project. This could be used for systemd, elogind (so no systemd), or anything else. I like to write it myself if that is ok. It was suggested to write `cpp`, but my preference would be `zig`. I'd write a package like `zshell-elogind-lock/` or similar. Would you be okay with zig in the project? In the end, it would be a binary that we'd end up using. What is your preference? Edit: Python is another option indeed in our current codebase.
AramJonghu moved this to Review in Zshell board on 2026-06-01 20:51:53 +02:00
Author
Collaborator

In the end, it will be a cpp plugin which can be enabled or disabled. I will update the original issue to show criteria.

In the end, it will be a `cpp` plugin which can be enabled or disabled. I will update the original issue to show criteria.
AramJonghu added reference lid-switch-behavior 2026-06-01 21:01:01 +02:00
AramJonghu changed reference from lid-switch-behavior to lid-switch-behavior 2026-06-01 21:08:35 +02:00
zach was unassigned by AramJonghu 2026-06-01 21:08:38 +02:00
AramJonghu self-assigned this 2026-06-01 21:08:39 +02:00
Author
Collaborator

@zach if you can assist.

Current issue I am facing is:

  WARN scene: @Daemons/LidService.qml[12:-1]: TypeError: Cannot read property 'lock' of undefined
  WARN scene: @Daemons/LidService.qml[12:-1]: TypeError: Cannot read property 'lock' of undefined
@zach if you can assist. Current issue I am facing is: ``` WARN scene: @Daemons/LidService.qml[12:-1]: TypeError: Cannot read property 'lock' of undefined WARN scene: @Daemons/LidService.qml[12:-1]: TypeError: Cannot read property 'lock' of undefined ```
zach closed this issue 2026-06-03 18:02:21 +02:00
AramJonghu moved this to Done in Zshell board on 2026-06-03 18:02:56 +02:00
Sign in to join this conversation.