I’m using KDE + Plasma Login Manager and a thinkpad x1 carbon. When I closed the lid, my monitor is the only display but up to a few mins later the laptop screen turns back on. I asked an llm and tried this configuration and a reboot but it didn’t work. I also have declared imports = [ inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x1-13th-gen];. How can I keep clamshell mode?
services.logind.settings.Login = {
handleLidSwitch = "suspend";
handleLidSwitchExternalPower = "ignore";
# If you use a dock or external monitor regularly:
handleLidSwitchDocked = "ignore";
};
This can be caused by a number of things. Clamshell mode in theory is quite simple, but there are a few different daemons involved in getting the right behavior.
The first is what you’ve configured right now - logind. It listens for the laptop lid close event to suspend your laptop when you close the lid. Since your laptop wasn’t suspending, it clearly wasn’t the culprit.
Still, your configuration effectively tells logind to just not suspend when you’re connected to A/C or if you’re docked. I’d personally recommend not setting those settings because there’s a much better mechanism for preventing this that still allows the laptop to go to sleep the moment you unplug A/C or remove the dock (logind inhibitors).
The next daemon that will attempt to handle these kinds of events is your display manager. It’s in charge of drawing to and controlling your displays, so it is the thing that should turn off your internal display when the lid is closed. Since logind doesn’t suspend your system, this is most likely the culprit.
The display manager also generally holds a sleep inhibitor when it detects that you’re trying to use the device in clamshell mode, which is why the logind configuration settings are probably not helpful.
You’ve not told us what display manager you use, though, and any bugs/configuration/etc. will be specific to the display manager, so I can’t give you any further context.
The final thing involved in all of this is the actual hardware. If it sends a spurious “no longer closed” event to the display manager, it might turn back on the display (as you describe), and simply not detect that the display is closed afterwards. This could be caused by anything from firmware to kernel bugs.
Right, are you using a plasma session then? x11 or Wayland? Sorry, I s/compositor/display manager/'d because it’s Thursday evening.
Do you get anything helpful from journalctl -f if you start it with the lid open and the display connected, then close the lid and wait until the internal display wakes up?
My plasma power settings look fine, I set it to do nothing when idle and plugged in. I’m using plasma wayland.
Output of journactl -f
Sep 24 11:48:54 NixOS-Laptop systemd-logind[905]: Lid closed.
Sep 24 11:48:54 NixOS-Laptop org_kde_powerdevil[2019]: Lid action was suppressed because an external monitor is present
Sep 24 11:48:54 NixOS-Laptop plasmashell[1966]: requesting unexisting screen available rect -1
Sep 24 11:48:54 NixOS-Laptop plasmashell[1966]: Final member StackingOrder is overridden in class QQmlDMAbstractItemModelData. The override won't be used.
Sep 24 11:48:54 NixOS-Laptop plasmashell[1966]: Final member StackingOrder is overridden in class QQmlDMAbstractItemModelData. The override won't be used.
Sep 24 11:48:54 NixOS-Laptop plasmashell[1966]: Final member StackingOrder is overridden in class QQmlDMAbstractItemModelData. The override won't be used.
Sep 24 11:49:09 NixOS-Laptop plasmashell[1966]: Final member StackingOrder is overridden in class QQmlDMAbstractItemModelData. The override won't be used.
Sep 24 11:49:09 NixOS-Laptop plasmashell[1966]: requesting unexisting screen available rect -1
Sep 24 11:49:09 NixOS-Laptop plasmashell[1966]: Final member StackingOrder is overridden in class QQmlDMAbstractItemModelData. The override won't be used.
Sep 24 11:49:09 NixOS-Laptop plasmashell[1966]: Final member StackingOrder is overridden in class QQmlDMAbstractItemModelData. The override won't be used.
Sep 24 11:49:09 NixOS-Laptop plasmashell[1966]: Final member StackingOrder is overridden in class QQmlDMAbstractItemModelData. The override won't be used.
Sep 24 11:49:09 NixOS-Laptop plasmashell[1966]: Final member StackingOrder is overridden in class QQmlDMAbstractItemModelData. The override won't be used.
Sep 24 11:49:15 NixOS-Laptop plasma_waitforname[8341]: WaitForName: Service was not registered within timeout
Sep 24 11:49:15 NixOS-Laptop systemd[1453]: dbus-:1.2-org.kde.KSplash@1.service: Main process exited, code=exited, status=1/FAILURE
Sep 24 11:49:15 NixOS-Laptop systemd[1453]: dbus-:1.2-org.kde.KSplash@1.service: Failed with result 'exit-code'.
Does the ksplash thing happen reproducibly or is that a red herring? Looks to me like something is desperately trying to draw to your internal display, and eventually crashes.
Plasma is correctly suppressing the lid action, anyway, and there are no further messages about it, so this is definitely an issue with your Plasma configuration, or a bug in Plasma itself. You can remove that logind config.
actually, plasmashell[1966]: Final member StackingOrder is overridden in class QQmlDMAbstractItemModelData. The override won't be used. it doesn’t show up while the lid is open and only when the lid is closed. the ksplash message doesn’t show.
That will probably also be a red herring. I suspect this is a Plasma bug, or maybe some missing configuration, probably better to ask on their discourse.
Hah, wow, it’s like they didn’t even read your description. Nor do they actually seem to know what Plasma does? Plasma is clearly turning off your internal display, it’s just waking up again for one reason or another.
The source easily confirms this, too. powerdevil contains functionality to implement actions based on whether the lid is closed, including whether there is an external display. Five lines down you can see it also suppresses sleep by default if there is an external monitor, which should be obvious from the behavior and logs, but there’s hard proof.
So instead of configuring logind and acpid, use the Plasma battery applet to configure your laptop not to sleep when the lid is closed. Kinda the point of a DE, it should be fully integrated.
As for shutting down displays whose lids are closed, that’s implemented in KWin, and should be happening by default.
That behavior is hard-coded and you can’t misconfigure it. So yeah, this is almost certainly a bug. Write an issue for KWin.
I filed a bug report, but I checked the issue again … and somehow it disappeared. I checked an old configuration with sudo /nix/var/nix/profiles/system-37-link/bin/switch-to-configuration switch then rebooted, and its not there either. This issue has been really bothering me for days and I guess it’s now just gone?
I made a reminder to look at this again next saturday.