refactor(viewer): split start_viewer.sh into per-platform libs - #3161
Merged
Conversation
start_viewer.sh had grown to ~790 lines mixing shared boot setup with
three interleaved display paths (cage/wayland, eglfs, linuxfb), which
made it hard to follow and to change safely.
Extract the platform-specific bring-up and launch into
bin/lib/viewer/*.sh and reduce start_viewer.sh to an orchestrator that
runs shared setup then dispatches by DEVICE_TYPE:
bin/start_viewer.sh orchestrator: shared setup + dispatch
bin/lib/viewer/common.sh paths, pulseaudio, locale, scale
factor, render group, Plymouth,
direct-sudo launch, supervise loop
bin/lib/viewer/platform_wayland.sh cage launch (x86 / arm64 / pi5)
bin/lib/viewer/platform_eglfs.sh eglfs display wait + KMS card detect
bin/lib/viewer/platform_linuxfb.sh fb wait + HDMI-hotplug recovery
No behavior change: every command, comment, and guard is moved verbatim.
The former inline top-level blocks are wrapped in functions, and each
platform step keeps its own QT_QPA_PLATFORM / DEVICE_TYPE guard, so the
orchestrator can call them unconditionally in the same order the
monolithic script ran. COPY . /usr/src/app/ already ships the new lib
dir and the container CMD is unchanged.
Verified: every original content line is present verbatim in the new
files (only the two case-syntax ";;" lines changed indentation); bash -n
clean on all five files; the sourced libs load with no side effects; and
the refactored script boots and binds the display on a Pi 5.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
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.



What
bin/start_viewer.shhad grown to ~800 lines interleaving shared boot setup with three display paths (cage/wayland, eglfs, linuxfb). This splits it into an orchestrator plus per-platform libraries — pure structural refactor, no behavior change.Why it's safe
;;lines changing indentation.QT_QPA_PLATFORM/DEVICE_TYPE, so the orchestrator calls them unconditionally in the same order the monolithic script ran.COPY . /usr/src/app/already ships the newbin/lib/viewer/dir; the containerCMD ["bash", "./bin/start_viewer.sh"]is unchanged. Nothing else in the repo referencesstart_viewer.shinternals.Verification
bash -nclean on all five files; sourcing the libs defines 17 functions with no side effects at source time.Applied wlroots transform),grimcaptured, display renders at 3840×2160.SC2172trap-by-number,SC2181$?,SC2016single-quotedbash -c) — all pre-existing patterns carried over verbatim; SC2016 is a false positive (the${XDG_RUNTIME_DIR}is meant to expand in cage's child shell). Not touched, to keep this a no-behavior-change move.Follow-up to the headless-boot display-wedge fix (#3155, merged); the vc4 self-heal from that PR now lives in
platform_wayland.sh. Replaces the earlier stacked PR that GitHub auto-closed when its base branch was deleted on merge.🤖 Generated with Claude Code