I’m using KDE, NixOS, 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";
};
I’m using Plasma Login manager.
I added `enable = true` for logind then rebuilt my nix configuration then rebooted, but it didn’t work.
HandleLidSwitch = “suspend” puts the machine to sleep on lid close. for clamshell you want ignore on all three.
services.logind.settings.Login = {
HandleLidSwitch = “ignore”;
HandleLidSwitchExternalPower = “ignore”;
HandleLidSwitchDocked = “ignore”;
};
rebuild and reboot.
if the lid panel still lights up after that, in Plasma System Settings → Display and Monitor turn the internal panel off for the external layout. also check Power Management so lid close does nothing.
paste journalctl -b | grep -i lid | tail -20 after the rebuild if the panel still wakes.
I want to have the laptop screen on when the lid is open since I frequently switch between devices on my monitor.
Output of journalctl -b | grep -i lid | tail -20:
Sep 24 11:58:45 NixOS-Laptop kernel: DMAR-IR: Queued invalidation will be enabled to support x2apic and Intr-remapping.
Sep 24 11:58:45 NixOS-Laptop kernel: iommu: DMA domain TLB invalidation policy: lazy mode
Sep 24 11:58:45 NixOS-Laptop kernel: DMAR: dmar1: Using Queued invalidation
Sep 24 11:58:45 NixOS-Laptop kernel: DMAR: dmar0: Using Queued invalidation
Sep 24 11:58:45 NixOS-Laptop kernel: DMAR: dmar2: Using Queued invalidation
Sep 24 11:58:49 NixOS-Laptop kernel: input: Lid Switch as /devices/platform/PNP0C0D:00/input/input5
Sep 24 11:58:49 NixOS-Laptop kernel: ACPI: button: Lid Switch [LID]
Sep 24 11:58:50 NixOS-Laptop systemd-timesyncd[456]: Disabling NSCD because DNSSEC validation is turned off
Sep 24 11:58:50 NixOS-Laptop dbus-broker-launch[811]: Invalid group-name in /nix/store/82q46wnml2xir2gfwag8qsvbfiq9lpvk-system-path/share/dbus-1/system.d/org.supergfxctl.Daemon.conf +9: group="sudo"
Sep 24 11:58:50 NixOS-Laptop systemd-logind[884]: /etc/systemd/logind.conf:4: Unknown key 'handleLidSwitch' in section [Login], ignoring.
Sep 24 11:58:50 NixOS-Laptop systemd-logind[884]: /etc/systemd/logind.conf:5: Unknown key 'handleLidSwitchDocked' in section [Login], ignoring.
Sep 24 11:58:50 NixOS-Laptop systemd-logind[884]: /etc/systemd/logind.conf:6: Unknown key 'handleLidSwitchExternalPower' in section [Login], ignoring.
Sep 24 11:58:50 NixOS-Laptop systemd-logind[884]: Watching system buttons on /dev/input/event4 (Lid Switch)
Sep 24 11:58:50 NixOS-Laptop kernel: uas int3400_thermal processor_thermal_soc_slider processor_thermal_rfim led_class pinctrl_intel_platform usb_storage acpi_thermal_rel intel_hid processor_thermal_rapl xt_tcpudp sparse_keymap intel_rapl_common usbhid processor_thermal_wt_req processor_thermal_power_floor processor_thermal_mbox intel_pmc_ssram_telemetry xt_conntrack scsi_mod intel_vpu onboard_usb_dev intel_pmc_pwrm_telemetry evdev nf_conntrack int340x_thermal_zone scsi_common hid mac_hid nf_defrag_ipv6 serio_raw nf_defrag_ipv4 xt_pkttype nft_compat x_tables nf_tables sch_fq_codel kvm_intel kvm fuse i2c_i801 uinput loop i2c_smbus ctr i2c_mux i2c_dev irqbypass dmi_sysfs nvme nvme_core atkbd libps2 vivaldi_fmap i8042 xhci_pci nvme_keyring thunderbolt serio xhci_hcd nvme_auth xe btrfs libblake2b intel_vsec drm_ttm_helper ttm drm_buddy i2c_algo_bit drm_suballoc_helper video wmi gpu_sched drm_gpuvm drm_exec drm_gpusvm_helper drm_display_helper dm_mod raid6_pq cec xor configfs efivarfs autofs4
Sep 24 11:59:04 NixOS-Laptop systemd-logind[884]: Lid closed.
Sep 24 11:59:04 NixOS-Laptop org_kde_powerdevil[2011]: Lid action was suppressed because an external monitor is present
Sep 24 12:00:23 NixOS-Laptop systemd-logind[884]: Lid opened.
Sep 24 12:00:40 NixOS-Laptop systemd-logind[884]: Lid closed.
Sep 24 12:00:40 NixOS-Laptop org_kde_powerdevil[2011]: Lid action was suppressed because an external monitor is present
Sep 24 12:02:39 NixOS-Laptop systemd-logind[884]: Lid opened.
your journal is ignoring the lid keys. systemd wants PascalCase and nix wrote lowercase:
Unknown key ‘handleLidSwitch’
so those lid settings never got applied.
try doin this:
services.logind.settings.Login = {
HandleLidSwitch = “ignore”;
HandleLidSwitchExternalPower = “ignore”;
HandleLidSwitchDocked = “ignore”;
};
rebuild + reboot, then check:
grep -i HandleLid /etc/systemd/logind.conf
journalctl -b | grep -i ‘Unknown key.*[Ll]id’
for the panel coming back with the lid closed, in Plasma Display Configuration turn the laptop screen off while the external is connected, or:
kscreen-doctor output.eDP-1.disable
(swap eDP-1 for whatever kscreen-doctor -o shows)
lid open can still turn the internal back on from a saved kscreen layout if that layout has it enabled.
grep -i HandleLid /etc/systemd/logind.conf
HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore
HandleLidSwitchExternalPower=ignore
nixos config:
services.logind.settings.Login = {
enable = true;
HandleLidSwitch = "ignore";
HandleLidSwitchExternalPower = "ignore";
# If you use a dock or external monitor regularly:
HandleLidSwitchDocked = "ignore";
LidSwitchIgnoreInhibited = "no";
};
journalctl -b | grep -i 'Unknown key.*[Ll]id' doesn’t show anything (btw those are supposed to be single quotes right? It’s best to use the code format if you can)
logind sieht jetzt gut aus. der rest ist plasma der den edp panel wieder anmacht.
try doin this:
- System Settings → Display & Monitor → auf dem layout den laptop screen (eDP) Disable / turn off wenn der externe dran ist. speichern.
- oder im terminal wenn der deckel zu ist und der externe laeuft:
kscreen-doctor -o
kscreen-doctor output.eDP-1.disable
(name ggf anpassen, steht in -o)
- Power Management → Lid → nichts was den internal screen wieder aktiviert. suspend bleibt aus weil logind schon auf ignore steht.
wenn der panel nach ein paar minuten trotzdem wieder kommt, paste:
journalctl -b --user -u plasma-plasmashell.service | tail -40
kscreen-doctor -o
System Settings → Display & Monitor → on the layout, disable/turn off the laptop screen (eDP) when the external device is connected. Save.
I don’t see something like “disable/turn off the laptop screen (eDP) when the external device is connected. Save.”
And again, I want the laptop screen whenever the lid is open regardless of monitor connection. I want the screen off when its closed and connected.
I asked for help here as well, also no luck so far. They suggested journalctl -f, I get logs like the one below. I noticed whenever the lid is closed it shows a bunch of messages like Sep 24 11:49:09 NixOS-Laptop plasmashell[1966]: Final member StackingOrder is overridden in class QQmlDMAbstractItemModelData. The override won't be used., and it’s not there before the lid is closed or after its reopened.
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'.
yeah theres no separate “when external is connected” menu item. in Display & Monitor click the laptop screen rectangle in the layout, then flip Enabled off (or the power icon on that output). that only sticks for the current layout tho.
for what you actually want (lid open = eDP on, lid closed + external = eDP off) plasma wont do that by itself. try doin this:
-
with lid closed and external on, run:
kscreen-doctor -o
kscreen-doctor output.eDP-1.disable
(use the real name from -o if it isnt eDP-1)
-
with lid open:
kscreen-doctor output.eDP-1.enable
-
wire those to the lid with a tiny script. on nixos something like:
services.acpid.enable = true;
services.acpid.handlers.lid = {
event = "button/lid.";
action = ‘’
if grep -q closed /proc/acpi/button/lid//state; then
sudo -u YOURUSER DISPLAY=:0 WAYLAND_DISPLAY=wayland-0 kscreen-doctor output.eDP-1.disable
else
sudo -u YOURUSER DISPLAY=:0 WAYLAND_DISPLAY=wayland-0 kscreen-doctor output.eDP-1.enable
fi
‘’;
};
rebuild, close the lid, check kscreen-doctor -o still shows eDP disabled a few mins later.
your journal “Lid action was suppressed because an external monitor is present” is powerdevil skipping suspend (good). the StackingOrder / unexisting screen lines are plasma freaking out while eDP is in a weird half state, disabling it cleanly with kscreen-doctor usually calms that down.
again you should really use code formatting, since the quote characters got changed here.
I’m still having the issue, my config right now:
services.logind.settings.Login = {
enable = true;
HandleLidSwitch = "ignore";
HandleLidSwitchExternalPower = "ignore";
# If you use a dock or external monitor regularly:
HandleLidSwitchDocked = "ignore";
LidSwitchIgnoreInhibited = "no";
};
services.acpid = {
enable = true;
handlers.lid = {
event = "button/lid.*";
action = ''
uid=$(${pkgs.util-linux}/bin/runuser -u USERNAME -- id -u)
export XDG_RUNTIME_DIR=/run/user/$uid
if grep -q closed /proc/acpi/button/lid/*/state; then
${pkgs.sudo}/bin/sudo -u USERNAME XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR WAYLAND_DISPLAY=wayland-0 ${pkgs.kdePackages.libkscreen}/bin/kscreen-doctor output.eDP-1.disable
else
${pkgs.sudo}/bin/sudo -u USERNAME XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR WAYLAND_DISPLAY=wayland-0 ${pkgs.kdePackages.libkscreen}/bin/kscreen-doctor output.eDP-1.enable
fi
'';
};
};
This is the output of journalctl -fxeu acpid, the acpid script seems to be working:
Sep 26 01:11:40 NixOS-Laptop acpid[19087]: Disabling output 2
Sep 26 01:11:40 NixOS-Laptop sudo[19084]: pam_unix(sudo:session): session closed for user USERNAME
Sep 26 01:11:41 NixOS-Laptop runuser[19106]: pam_unix(runuser:session): session opened for user USERNAME(uid=1000) by (uid=0)
Sep 26 01:11:41 NixOS-Laptop runuser[19106]: pam_unix(runuser:session): session closed for user USERNAME
Sep 26 01:11:41 NixOS-Laptop sudo[19109]: root : PWD=/ ; USER=USERNAME ; ENV=XDG_RUNTIME_DIR=/run/user/1000 WAYLAND_DISPLAY=wayland-0 ; COMMAND=/nix/store/4crkwq9ry8va93f831941xzn3k3rmsgb-libkscreen-6.7.5/bin/kscreen-doctor output.eDP-1.enable
Sep 26 01:11:41 NixOS-Laptop sudo[19109]: pam_unix(sudo:session): session opened for user USERNAME(uid=1000) by (uid=0)
Sep 26 01:11:41 NixOS-Laptop acpid[19111]: Enabling output 2
Sep 26 01:11:41 NixOS-Laptop sudo[19109]: pam_unix(sudo:session): session closed for user USERNAME