DankMaterialShell icon indicating copy to clipboard operation
DankMaterialShell copied to clipboard

`lock before suspend` does not work

Open bokicoder opened this issue 1 year ago • 54 comments

Compositor

  • [x] niri
  • [ ] Hyprland
  • [ ] Other (specify)

Description

After suspending the system and waking it up, the screen was not locked, and after that, whether through IPC or the control center, the screen could no longer be locked unless the DMS was restarted.

But if you lock the screen first and then suspend the system, there is no issue.

bokicoder avatar Oct 11 '25 09:10 bokicoder

It requires gdbus to be able to access loginctl dbus interfaces, unless you start the shell with dms run which provides native dbus connections (for lock before suspend and other things)

For this issue, logs would be helpful. You can grab them by.

dms kill
mkdir ~/dms_logs
nohup dms run > ~/dms_logs/dms-$(date +%s).txt 2>&1 &

Then once you trigger the issue you can share the contents of ~/dms_logs/dms-.txt

bbedward avatar Oct 11 '25 14:10 bbedward

@bbedward

dms-1760193778.txt

bokicoder avatar Oct 11 '25 14:10 bokicoder

Is there a chance its running without access to $XDG_SESSION_ID ? Logs dont say much, I may need to add some more debug output to it

bbedward avatar Oct 11 '25 15:10 bbedward

You can also check loginctl lock-session $XDG_SESSION_ID see if that works - that would at least show loginctl is connected

bbedward avatar Oct 11 '25 15:10 bbedward

你也可以检查 loginctl lock-session $XDG_SESSION_ID 看看是否有效 - 那至少能显示 loginctl 是否已连接

It works

bokicoder avatar Oct 11 '25 15:10 bokicoder

@bbedward I logged and reviewed the dbus messages and found that there are no corresponding dbus calls after waking up from a suspended state, regardless of how the screen is locked

bokicoder avatar Oct 11 '25 16:10 bokicoder

I can't reproduce it, but I think I'm going to do some enhancements to have the go side create a sleep inhibitor to help guarantee we get the prepare for sleep event and have enough time to lock.

We dont really care about any wakeup signals here, just want the loginctl notification that the system is preparing for suspending.

bbedward avatar Oct 11 '25 16:10 bbedward

We dont really care about any wakeup signals here, just want the loginctl notification that the system is preparing for suspending.

This? Image

Image

bokicoder avatar Oct 11 '25 17:10 bokicoder

That is the one that it is listening to right now, I'm re-engineering this to include a sleep inhibitor and change some structure around - I suspect the issue might be that systemd is not giving enough time for the lock screen to show up (due to lack of sleep inhibitor bein created, telling systemd we need some time to prepare)

bbedward avatar Oct 11 '25 17:10 bbedward

I did d a suite of breaking API changes 3a7777c6431de17c38cb5a457c972675f32fb491

It includes this work, as well. Remove prepare for sleep handling from QML entirely, dms dbus connection creates a sleep inhibitor and handles locking, if lock before suspend is enabled.

I would see - if that handles it.

If still no - you can do DMS_VERBOSE_LOGGING=1 dms run... to get more verbose logs to see whats up

bbedward avatar Oct 11 '25 18:10 bbedward

Image

                                  
██████╗  █████╗ ███╗   ██╗██╗  ██╗
██╔══██╗██╔══██╗████╗  ██║██║ ██╔╝
██║  ██║███████║██╔██╗ ██║█████╔╝ 
██║  ██║██╔══██║██║╚██╗██║██╔═██╗ 
██████╔╝██║  ██║██║ ╚████║██║  ██╗
╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝
  INFO  go: DMS API Server listening on: /run/user/1000/danklinux-8827.sock
  INFO  go: Protocol: JSON over Unix socket
  INFO  go: Request format: {"id": <any>, "method": "...", "params": {...}}
  INFO  go: Response format: {"id": <any>, "result": {...}} or {"id": <any>, "error": "..."}
  INFO  go: Loginctl manager initialized
  INFO  go: Network manager initialized
  INFO  go: Freedesktop manager initialized
  INFO: Launching config: "/nix/store/kw7m4j0m01fm01js7jc2ncdrkkafpkx6-dankMaterialShell/etc/xdg/quickshell/DankMaterialShell/shell.qml"
  INFO: Shell ID: "a86c01df418a6abf0d7c249380a3abc7" Path ID "a86c01df418a6abf0d7c249380a3abc7"
  INFO: Saving logs to "/run/user/1000/quickshell/by-id/ht6vrzz3t/log.qslog"
 DEBUG qml: NetworkService: Initializing...
 DEBUG qml: NetworkService: DMS_SOCKET found, waiting for capabilities...
  INFO: Configuration Loaded
  WARN scene: QML FileView at @Common/SettingsData.qml[1503:5]: Read of /home/super6/.config/DankMaterialShell/plugin_settings.json failed: File does not exist.
  WARN scene: QML FileView at @Common/Theme.qml[896:5]: Read of /home/super6/.cache/quickshell/dankshell/dms-colors.json failed: File does not exist.
 DEBUG qml: I18n: Using locale 'zh_CN' from file:///nix/store/kw7m4j0m01fm01js7jc2ncdrkkafpkx6-dankMaterialShell/etc/xdg/quickshell/DankMaterialShell/translations/poexports/zh_CN.json
  WARN scene: QML FileView at @Services/NotepadStorageService.qml[266:9]: Read of /home/super6/.local/state/DankMaterialShell/notepad-files/untitled-1760161840695.txt failed: File does not exist.
 DEBUG qml: I18n: Loaded translations for 'zh_CN' (463 contexts)
  WARN scene: QML FileView at @Services/NotepadStorageService.qml[266:9]: Read of /home/super6/.local/state/DankMaterialShell/notepad-files/untitled-1760161840695.txt failed: File does not exist.
 DEBUG qml: Detected distribution: NixOS 25.11 (Xantusia)
 DEBUG qml: Adding ref for module: cpu count: 1
 DEBUG qml: Adding ref for module: memory count: 1
 DEBUG qml: Adding ref for module: cpu count: 2
 DEBUG qml: Adding ref for module: memory count: 2
 DEBUG  go: DMS API Request: method=subscribe id=0
 ERROR  go: DMS API Error: id=0 error=unknown method: subscribe
 ERROR qml: DMSService: Server does not support subscribe method
 DEBUG qml: IdleService: Initialized with idle monitoring support
 DEBUG qml: CompositorService: Detected Niri with socket: /run/user/1000/niri.wayland-1.1873.sock
 DEBUG qml: NiriService: Generating binds config...
  WARN qml: NiriService: Failed to write binds config, exit code: 1
 DEBUG qml: NiriService: Loaded 1 outputs
 DEBUG qml: NiriService: Loaded 1 outputs
 DEBUG qml: SessionService: Native inhibitor available: true
 DEBUG qml: NiriService: Generating layout config...
 DEBUG qml: NiriService: Generated layout config at /home/super6/.config/niri/dms/layout.kdl
 DEBUG qml: SessionService: Elogind detection exited with code 1
 DEBUG qml: DankBar: Created native Wayland IdleInhibitor for eDP-1

bokicoder avatar Oct 12 '25 02:10 bokicoder

Whole package needs an update, dms CLI + the qml

bbedward avatar Oct 12 '25 03:10 bbedward

I know about this, but I was negligent when handling it. It's my fault.

bokicoder avatar Oct 12 '25 03:10 bokicoder

Now it's the lock screen that appears first, then the system waits for about 4 seconds before suspending, Is this normal?

bokicoder avatar Oct 12 '25 03:10 bokicoder

it's normal right now (because the lock screen isnt releasing the inhibitor) - which is one remaining enhancement. ONce lock screen is fully displayed & ready - it should release the inhibitor and then it wont delay as long.

bbedward avatar Oct 12 '25 03:10 bbedward

I see. Thank you.

bokicoder avatar Oct 12 '25 03:10 bokicoder

New release, v0.1.2 properly releases the inhibitor when the lock screen is loaded, removing the delay. It also requires another update to dms binary to get to API v2 (but doesnt brick any functionality, besides the delay).

I think we're good on the dms API syncing and qml side now so we can push API updates without breaking changes.

These things are not provided by quickshell, at all, so that's why dms is coming in and providing a native dbus interface to loginctl, accountsservice, networkmanager (its not required still, but its required to extend functionality to support things like this)

bbedward avatar Oct 12 '25 04:10 bbedward

New release, v0.1.2 properly releases the inhibitor when the lock screen is loaded, removing the delay. It also requires another update to dms binary to get to API v2 (but doesnt brick any functionality, besides the delay).

I think we're good on the dms API syncing and qml side now so we can push API updates without breaking changes.

These things are not provided by quickshell, at all, so that's why dms is coming in and providing a native dbus interface to loginctl, accountsservice, networkmanager (its not required still, but its required to extend functionality to support things like this)

No, this has caused the issue to recur.

bokicoder avatar Oct 12 '25 13:10 bokicoder

                                  
██████╗  █████╗ ███╗   ██╗██╗  ██╗
██╔══██╗██╔══██╗████╗  ██║██║ ██╔╝
██║  ██║███████║██╔██╗ ██║█████╔╝ 
██║  ██║██╔══██║██║╚██╗██║██╔═██╗ 
██████╔╝██║  ██║██║ ╚████║██║  ██╗
╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝
  INFO  go: DMS API Server listening on: /run/user/1000/danklinux-3425.sock
  INFO  go: Protocol: JSON over Unix socket
  INFO  go: Request format: {"id": <any>, "method": "...", "params": {...}}
  INFO  go: Response format: {"id": <any>, "result": {...}} or {"id": <any>, "error": "..."}
  INFO  go: Freedesktop manager initialized
  INFO  go: Network manager initialized
  INFO  go: Loginctl manager initialized
  INFO: Launching config: "/nix/store/7cs6hj4hd73j32cjijbdj1ay688pjys7-dankMaterialShell/etc/xdg/quickshell/DankMaterialShell/shell.qml"
  INFO: Shell ID: "1395eb9a15573668b3a6c7c3d1918a76" Path ID "1395eb9a15573668b3a6c7c3d1918a76"
  INFO: Saving logs to "/run/user/1000/quickshell/by-id/fn2htt04t/log.qslog"
 DEBUG qml: NetworkService: Initializing...
 DEBUG qml: NetworkService: DMS_SOCKET found, waiting for capabilities...
  INFO: Configuration Loaded
  WARN scene: QML FileView at @Common/SettingsData.qml[1503:5]: Read of /home/super6/.config/DankMaterialShell/plugin_settings.json failed: File does not exist.
  WARN scene: QML FileView at @Common/Theme.qml[896:5]: Read of /home/super6/.cache/quickshell/dankshell/dms-colors.json failed: File does not exist.
 DEBUG qml: I18n: Using locale 'zh_CN' from file:///nix/store/7cs6hj4hd73j32cjijbdj1ay688pjys7-dankMaterialShell/etc/xdg/quickshell/DankMaterialShell/translations/poexports/zh_CN.json
 DEBUG qml: I18n: Loaded translations for 'zh_CN' (463 contexts)
  WARN scene: QML FileView at @Services/NotepadStorageService.qml[266:9]: Read of /home/super6/.local/state/DankMaterialShell/notepad-files/untitled-1760250993595.txt failed: File does not exist.
  WARN scene: QML FileView at @Services/NotepadStorageService.qml[266:9]: Read of /home/super6/.local/state/DankMaterialShell/notepad-files/untitled-1760250993595.txt failed: File does not exist.
 DEBUG qml: Detected distribution: NixOS 25.11 (Xantusia)
 DEBUG qml: Adding ref for module: cpu count: 1
 DEBUG qml: Adding ref for module: memory count: 1
 DEBUG qml: Adding ref for module: cpu count: 2
 DEBUG qml: Adding ref for module: memory count: 2
 DEBUG  go: DMS API Request: method=subscribe id=0
 DEBUG  go: DMS API Request: method=loginctl.getState id=1760276214479
 DEBUG  go: DMS API Request: method=loginctl.setLockBeforeSuspend id=1760276214480
 DEBUG qml: NetworkService: Network capability detected, using NetworkManagerService
 DEBUG qml: NetworkService: Switched to NetworkManagerService, networkAvailable: true
 DEBUG qml: DMSService: Connected (API v2) - ["plugins","network","loginctl","freedesktop"]
 DEBUG  go: DMS API Request: method=network.getState id=1760276214481
 DEBUG qml: SessionService: Synced lock before suspend: true
 DEBUG  go: DMS API Request: method=network.wifi.scan id=1760276214483
 DEBUG  go: DMS API Request: method=network.getState id=1760276214512
 DEBUG qml: IdleService: Initialized with idle monitoring support
 DEBUG qml: CompositorService: Detected Niri with socket: /run/user/1000/niri.wayland-1.1881.sock
 DEBUG qml: NiriService: Generating binds config...
  WARN qml: NiriService: Failed to write binds config, exit code: 1
 DEBUG qml: NiriService: Loaded 1 outputs
 DEBUG qml: NiriService: Loaded 1 outputs
 DEBUG qml: SessionService: Native inhibitor available: true
 DEBUG qml: NiriService: Generating layout config...
 DEBUG qml: NiriService: Generated layout config at /home/super6/.config/niri/dms/layout.kdl
 DEBUG qml: SessionService: Elogind detection exited with code 1
 DEBUG qml: DankBar: Created native Wayland IdleInhibitor for eDP-1
 DEBUG  go: DMS API Request: method=freedesktop.getState id=1760276223917
 DEBUG  go: DMS API Request: method=freedesktop.getState id=1760276223918
 DEBUG  go: DMS API Request: method=loginctl.lockerReady id=1760276223923
 DEBUG qml: LockScreenContent: Locker ready signaled, inhibitor released
 DEBUG  go: DMS API Request: method=freedesktop.settings.getColorScheme id=1760276223925

bokicoder avatar Oct 12 '25 13:10 bokicoder

@bbedward To troubleshoot the issue, I tried using dms locker alongside swayidle. Interestingly, there were no issues at all, which suggests...

bokicoder avatar Oct 12 '25 15:10 bokicoder