Skip to content

stl-game-config: check_kde_hdr_enabled always returns false (ANSI codes + wrong output picked) #182

Description

@St0nefish

Problem

plugins-claude/stl-game-config/scripts/system-info.sh:48-69 (check_kde_hdr_enabled)
reports kde_hdr_enabled: false on a system where KDE HDR is demonstrably enabled.

Two independent defects, either of which is sufficient to break it.

1. ANSI escape codes defeat the literal grep

kscreen-doctor colorizes its output even when stdout is a pipe, so the line is:

^[[01;33m<TAB>HDR: ^[[0;0menabled

There is a color-reset sequence between the label and the value, so the literal
substring HDR: enabled never appears and grep -q "HDR: enabled" (line 64) can
never match:

$ kscreen-doctor -o | grep -c "HDR: enabled"
0

The function therefore returns false unconditionally on any host where
kscreen-doctor emits color through a pipe — regardless of display state.

2. head -1 picks an arbitrary output, not the primary

Line 60 comments "Get primary output", but line 62 does no primary detection —
it takes the first line matching HDR|DDC across all outputs. On a multi-display
system that is whichever output kscreen-doctor happens to list first:

Output: 1 DP-2  ->  HDR: incapable     <- non-HDR secondary, listed first
Output: 2 DP-3  ->  HDR: enabled       <- actual primary, HDR on

Even with defect 1 fixed, this host would read the secondary display and still
report false.

The |DDC alternation in that grep is also dead weight — a DDC/CI: line can only
ever win the head -1 race and guarantee a non-match.

Reproduction

On KDE Wayland with two displays, one HDR-capable with HDR enabled and one not,
where the non-HDR display is listed first by kscreen-doctor -o:

$ bash plugins-claude/stl-game-config/scripts/system-info.sh
{
  "gpu_vendor": "nvidia",
  "compositor": "kde",
  "kde_hdr_enabled": false
}

$ kscreen-doctor -o | grep -E "Output|HDR"
Output: 1 DP-2 ...
	HDR: incapable
Output: 2 DP-3 ...
	HDR: enabled

Expected kde_hdr_enabled: true.

Suggested fix

Strip ANSI before matching, drop the DDC alternation, and decide what "enabled"
means across multiple outputs — either resolve the actual primary, or report true
if any output has HDR enabled (probably the more useful signal for a
"can this box do HDR right now" check).

Sketch:

kscreen-doctor -o 2>/dev/null \
  | sed 's/\x1b\[[0-9;]*m//g' \
  | grep -qE '^[[:space:]]*HDR:[[:space:]]*enabled' && echo true || echo false

Consider also having kscreen-doctor emit uncolored output if it supports a flag
for that, rather than stripping after the fact.

Impact

Callers get a false negative and will route a game away from the HDR path (or
report HDR as unavailable) on a correctly configured HDR display.

Note stl-info.sh is unaffected — it has no display-HDR detection at all.

Environment

  • CachyOS (Arch-based), KDE Plasma on Wayland
  • NVIDIA RTX 5090, nvidia-open-dkms 610.57.04
  • Displays: MSI MPG341CX OLED 3440x1440 @ 240Hz (HDR enabled, primary), ASUS ROG PG348Q (HDR incapable)
  • stl-game-config plugin 1.2.1; identical code present in the source tree at the same lines

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions