Skip to content

logind suspends laptop on DPMS-off when lid is closed #41898

@Nikratio

Description

@Nikratio

systemd version the issue has been seen with

258.7

Used distribution

Fedora 43

Linux kernel version used

6.19.13-200.fc43.x86_64

CPU architectures issue was seen on

x86_64

Component

systemd-logind

Expected behaviour you didn't see

I am using a laptop with a closed lid and an external display. When blanking the external display through DPMS, I expect this not to affect the state of the laptop.

Unexpected behaviour you saw

When powering off the screen, my system suspends.

This seems to be because logind enumerates DRM connectors and counts a connector only if its sysfs enabled attribute equals the literal string "enabled" - but when DPMS is on, it has a different value (at least for the amdgpu DRM driver, in report enabled based on whether the connector is currently driving an active CRTC, not whether the connector is physically present.)

Therefore, when a userspace compositor (swayidle in my case) sends a DPMS-off ioctl, the CRTC is detached and the kernel flips enabled from enabled to disabled — even though the cable is still plugged in and status remains connected.

Steps to reproduce the problem

  1. Close laptop lid with a single external monitor connected via DisplayPort. Confirm HandleLidSwitch=suspend, HandleLidSwitchDocked=ignore (defaults), and IdleAction=ignore (default).
  2. Confirm busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager Docked returns b true.
  3. From a terminal on the laptop, run a DPMS-off command, e.g. on Sway: swaymsg "output * dpms off".
  4. Observe: the laptop suspends within a fraction of a second.

Additional program output to the terminal or log subsystem illustrating the issue

before and after swaymsg "output * dpms off", on a Lenovo ThinkPad with a single DP monitor:                                                            
  
  # Before:                                                                                                                                                                            
  /sys/class/drm/card1-DP-3/status: connected (enabled=enabled)                                                                                                                      
  Docked = b true                                                                                                                                                                      
  
  # After:                                                                                                                                                                             
  /sys/class/drm/card1-DP-3/status: connected (enabled=disabled)                                                                                                                     
  Docked = b false     


Suggested patch (generated with Claude Code, not reviewed by me, I do not know enough about systemd):

In src/login/logind-core.c, manager_count_external_displays(), drop the enabled check entirely and rely on status != "disconnected" (which the code already does immediately afterwards).

Looking at the same function, there's a missing comma in the prefix list:                                                                   
  if (!STARTSWITH_SET(dash,
                      "VGA-", "DVI-I-", "DVI-D-", "DVI-A-"                                                                                                                             
                      "Composite-", "SVIDEO-", "Component-",                                                                                                                           
                      "DIN-", "DP-", "HDMI-A-", "HDMI-B-", "TV-"))                                                                                                                     

Adjacent string literal concatenation turns "DVI-A-" "Composite-" into the single token "DVI-A-Composite-", so DVI-A and Composite connectors are both never matched. (Probably    
  worth fixing in the same patch.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Programming errors, that need preferential fixinglogin

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions