Batocera-CRT-Script-v44.sh - #449
Open
ZFEbHVUE wants to merge 1 commit into
Open
Conversation
Add Batocera-CRT-Script-v44.sh It should be work only for V44 !
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.