Skip to content

Fix profile detection when lid state differs from save time#423

Open
elstonj wants to merge 1 commit into
phillipberndt:masterfrom
elstonj:fix-lid-profile-detection
Open

Fix profile detection when lid state differs from save time#423
elstonj wants to merge 1 commit into
phillipberndt:masterfrom
elstonj:fix-lid-profile-detection

Conversation

@elstonj

@elstonj elstonj commented Mar 23, 2026

Copy link
Copy Markdown

Summary

  • eDP/LVDS lid exemption in find_profiles: Profiles saved with the laptop lid closed don't include the eDP/LVDS output's EDID in the setup file. When the lid is later opened, find_profiles rejects the profile because the eDP output has a fingerprint but isn't in the profile config. Fix: exempt eDP/LVDS outputs from the completeness check, since they may not have been present at save time due to a closed lid.

  • Closeness calculation bug: The closeness score used stale loop variables (output, name) left over from the preceding for loop iteration, rather than computing across all profile outputs. This could produce incorrect rankings or crash on profiles with edid=None outputs. Fix: iterate all config items and use min closeness across outputs with valid EDIDs.

  • is_closed_lid regex: \+ (literal plus) should be + (one-or-more quantifier) for matching output names like eDP-1. Worked by accident because the * quantifier allowed zero matches of the group, but was incorrect.

Test plan

  • Save a profile with the laptop lid closed (e.g. docked with external monitor only)
  • Open the lid and run autorandr — the docked profile should be detected
  • Verify that less-specific profiles (e.g. laptop-only default) are NOT detected when external monitors are connected
  • Verify profiles with EDID wildcards still rank correctly by closeness

Two issues in find_profiles prevented correct profile detection when
a laptop's lid state at detection time differed from when the profile
was saved:

1. The completeness check required ALL connected outputs with
   fingerprints to be present in the profile config. Profiles saved
   with the lid closed would not include the eDP/LVDS output's EDID
   in the setup file, so when the lid was later opened, the profile
   would not be detected despite the external monitors matching.

   Fix: exempt eDP and LVDS outputs from the completeness check,
   since these may not have been present when the profile was saved
   due to a closed lid.

2. The closeness calculation used stale loop variables (output, name)
   from the preceding for loop iteration rather than computing across
   all profile outputs. This could produce incorrect rankings or crash
   on profiles with edid=None outputs.

   Fix: iterate all config items and use min closeness across outputs
   with valid EDIDs.

Also fix is_closed_lid regex where \+ (literal plus) should be +
(one-or-more quantifier) for matching output names like eDP-1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants