Skip to content

Batocera-CRT-Script-v44.sh - #449

Open
ZFEbHVUE wants to merge 1 commit into
mainfrom
ZFEbHVUE-patch--BatoceraCRTScriptv44
Open

Batocera-CRT-Script-v44.sh#449
ZFEbHVUE wants to merge 1 commit into
mainfrom
ZFEbHVUE-patch--BatoceraCRTScriptv44

Conversation

@ZFEbHVUE

@ZFEbHVUE ZFEbHVUE commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Add Batocera-CRT-Script-v44.sh
It should be work only for V44 !

v43 → v44: xrandr output detection fix

Problem

On Batocera v44, the CRT script failed at the output-detection stage with:

No outputs found via xrandr. Is X running?
ERROR: Cannot proceed without xrandr outputs.

even though X was running correctly and xrandr worked fine when run manually from a shell.

Root cause

The script called xrandr with DISPLAY=:0 but never set XAUTHORITY. Batocera starts the X server with an explicit auth cookie:

/usr/bin/X :0 -auth //.serverauth.

Without pointing XAUTHORITY at that file, any xrandr call made outside the exact session that owns the cookie (SSH, a subshell, a non-ES context) is rejected by the X server with:

Authorization required, but no authorization protocol specified
Can't open display :0

xrandr then returns no outputs, and the script aborts. This did not surface the same way on v43 due to differences in how/where the script was invoked relative to the X auth context.

Fix

A new helper, ensure_x_authority(), is called at the start of output_detection_and_persist(), before any xrandr query. It:

Returns immediately if xrandr --query already works (normal ES launch — nothing to do).
Otherwise resolves the cookie, in order:
the exact -auth path from the running X server's command line (ps + regex on .serverauth.),
the newest .serverauth.* in common locations,
standard .Xauthority files.
Exports XAUTHORITY so every subsequent xrandr call in the script inherits it.
Falls back to xhost +local: as a last resort for a local root X server.

This makes output detection robust regardless of how the script is launched (ES, SSH, subshell).

Note

This fix only applies to X11 (Xorg) sessions. If Batocera boots into Wayland, xrandr is unavailable entirely and XAUTHORITY is irrelevant — that is a separate concern requiring an X11 session for CRT/Switchres to function.

Tu peux raccourcir encore si besoin, mais l'essentiel pour un reviewer c'est : missing XAUTHORITY → X auth rejection → zero outputs → abort, et le fix résout le cookie automatiquement.

Add Batocera-CRT-Script-v44.sh
It should be work only for V44 !
@Redemp Redemp changed the title Add files via upload Batocera-CRT-Script-v44.sh Jul 12, 2026
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.

1 participant