Fix installer cosmetics: gum colours, highlighting, garbled menus

Three fixes for the degraded look of the Omarchy install phase on
real hardware:

- .zlogin piped the whole installer through `tee /dev/ttyS0` whenever
  ttyS0 was writable — true on nearly every real PC, not just QEMU.
  gum then saw a pipe instead of a TTY and dropped colours and
  selection highlighting, and redraws garbled into stray characters.
  Serial logging is now gated on QEMU DMI detection and uses
  script(1) — a pty — so even VM test runs render correctly while
  still logging to the serial port.

- Only 3 of the 16 Tokyo Night console palette entries were set, so
  gum's accent colours fell back to the default VGA palette. Added
  the full set_tokyo_night_colors() (same escapes as the stock
  .automated_script.sh), applied at menu start and before the
  configurator.

- WINOMA_ON_VT exported by .zlogin so the palette guard also fires
  inside script's pty, where $(tty) reports a pts instead of the VT.

Verified: headless QEMU smoke test (menu, serial log via pty, palette
escapes in stream) + full install on real hardware.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
28allday 2026-06-06 21:10:30 +01:00
parent c3f205c282
commit 18447cda28

View file

@ -122,6 +122,36 @@ header() {
echo "" echo ""
} }
# Full Tokyo Night console palette — same 16 entries the stock Omarchy
# .automated_script.sh sets. Setting only bg/fg leaves gum's accent colours
# (yellow "Installing...", blue selection bars) on the harsh default VGA
# palette, which is what "lost its Omarchy colours" looks like.
set_tokyo_night_colors() {
# WINOMA_ON_VT: set by .zlogin when we boot on tty1 but run inside
# script(1)'s pty for QEMU serial logging — $(tty) is /dev/pts/0 then,
# yet output still lands on the VT, so the palette escapes are safe.
if [[ $(tty) == "/dev/tty"* || -n "${WINOMA_ON_VT:-}" ]]; then
echo -en "\e]P01a1b26" # black (background)
echo -en "\e]P1f7768e" # red
echo -en "\e]P29ece6a" # green
echo -en "\e]P3e0af68" # yellow
echo -en "\e]P47aa2f7" # blue
echo -en "\e]P5bb9af7" # magenta
echo -en "\e]P67dcfff" # cyan
echo -en "\e]P7a9b1d6" # white
echo -en "\e]P8414868" # bright black
echo -en "\e]P9f7768e" # bright red
echo -en "\e]PA9ece6a" # bright green
echo -en "\e]PBe0af68" # bright yellow
echo -en "\e]PC7aa2f7" # bright blue
echo -en "\e]PDbb9af7" # bright magenta
echo -en "\e]PE7dcfff" # bright cyan
echo -en "\e]PFc0caf5" # bright white (foreground)
echo -en "\033[0m"
clear
fi
}
cleanup_and_exit() { cleanup_and_exit() {
warn "Setup cancelled or failed. Cleaning up..." warn "Setup cancelled or failed. Cleaning up..."
umount -R /mnt 2>/dev/null || true umount -R /mnt 2>/dev/null || true
@ -381,6 +411,8 @@ WINREPAIR
# MAIN MENU # MAIN MENU
#=============================================================================== #===============================================================================
set_tokyo_night_colors
header "OMARCHY DUAL-BOOT INSTALLER" header "OMARCHY DUAL-BOOT INSTALLER"
echo "This installer will set up Omarchy alongside Windows." echo "This installer will set up Omarchy alongside Windows."
@ -674,14 +706,8 @@ export OMARCHY_PATH=/root/omarchy
export OMARCHY_INSTALL=/root/omarchy/install export OMARCHY_INSTALL=/root/omarchy/install
source "$OMARCHY_INSTALL/helpers/all.sh" 2>/dev/null || true source "$OMARCHY_INSTALL/helpers/all.sh" 2>/dev/null || true
# Set colors # Set the full Tokyo Night palette (re-applied here in case anything reset it)
if [[ $(tty) == "/dev/tty"* ]]; then set_tokyo_night_colors
echo -en "\e]P01a1b26"
echo -en "\e]P7a9b1d6"
echo -en "\e]PFc0caf5"
echo -en "\033[0m"
clear
fi
# Drain any buffered keystrokes / stray terminal bytes left over from the # Drain any buffered keystrokes / stray terminal bytes left over from the
# "Press Enter" prompt and the logo animation, so they don't leak into the # "Press Enter" prompt and the logo animation, so they don't leak into the
@ -1285,14 +1311,23 @@ if [[ -f "$WORK_DIR/extracted/root/.automated_script.sh" ]]; then
fi fi
# Replace .zlogin to run our dual-boot setup # Replace .zlogin to run our dual-boot setup
# When a serial port exists (e.g. running under QEMU with -serial), tee the # Under QEMU (vm-test.sh with -serial), mirror the installer's output to
# installer's full stdout+stderr to it so the host can capture a forensic log # /dev/ttyS0 so the host can capture a forensic log without scraping the
# of the install run without scraping the QEMU window. # QEMU window. Two things matter here:
# 1. Gate on QEMU via DMI — /dev/ttyS0 exists and is root-writable on
# nearly every REAL PC too, so a bare -w check used to pipe the whole
# installer through tee on hardware. gum then saw a pipe instead of a
# TTY and dropped colours/highlighting, and redraws garbled.
# 2. Use script(1) (a pty), not tee (a pipe), so gum still detects a real
# terminal even when logging — VM runs render correctly too.
cat > "$WORK_DIR/extracted/root/.zlogin" << 'EOF' cat > "$WORK_DIR/extracted/root/.zlogin" << 'EOF'
# Omarchy Dual-Boot Installer # Omarchy Dual-Boot Installer
if [[ $(tty) == "/dev/tty1" ]]; then if [[ $(tty) == "/dev/tty1" ]]; then
if [[ -w /dev/ttyS0 ]]; then # We're on the VT console — tell set_tokyo_night_colors it's safe to set
/root/dualboot-setup.sh 2>&1 | tee /dev/ttyS0 # the kernel palette even when $(tty) is a pts (inside script's pty below).
export WINOMA_ON_VT=1
if grep -qi qemu /sys/class/dmi/id/sys_vendor 2>/dev/null && [[ -w /dev/ttyS0 ]]; then
script -qefc /root/dualboot-setup.sh /dev/ttyS0
else else
/root/dualboot-setup.sh /root/dualboot-setup.sh
fi fi