This document describes the technical implementation of Up Linux, including installation flow, state management, theming system, and key design patterns.
Up Linux uses a two-phase installation process that transitions from the Arch ISO environment to the installed system:
- Host Phase (
bootstrap.sh): Runs from Arch ISO, handles disk operations - Chroot Phase (
setup.sh): Runs inside installed system, handles configuration
These steps must succeed (no silent || true):
- Partition creation with checked exit codes +
wait_for_partitionsdevice asserts - Mount of root (and EFI/boot as applicable)
- GRUB install +
grub-mkconfigproducing/boot/grub/grub.cfg - Generation of
~/.config/i3/keybindings.conf(viawrite_i3_keybindings_file) - Polybar launched through
~/.config/polybar/launch.sh
partition_device disk N in configs/scripts/partition-utils.sh:
nvme*,mmcblk*,loop*,nbd*,md*→${disk}p${N}- otherwise →
${disk}${N}
Cleanup uses the same library (cleanup_partitions) and must never source bootstrap.sh.
Preferred: XLibre from [xlibre-stable] (https://packages.xlibre.net/arch/stable/$arch, key B97F7C613F359424). On failure after retries: xorg-server + xf86-input-libinput. Recorded as DISPLAY_STACK in the install report.
install.sh owns progress_total.txt. Phase scripts read it into PROGRESS_TOTAL and pass it to update_progress.
The installation uses bind mounts to share state between the host (Arch ISO) and chroot (new system) environments:
Host: /tmp/up-state/ ──bind mount──┬─ Chroot: /up-state/
Host: /var/log/up/ ──bind mount───┴─ Chroot: /var/log/up/
Implementation Details:
- Bind mounts created in
bootstrap.shbeforearch-chroot - Enables real-time progress updates during pacstrap
- State files coordinate between tmux watcher panes
- Cleanup handled in both error handlers and normal exit
The installer uses tmux with 4 synchronized panes:
- Title Pane (top): Branding and status
- Phases Pane (middle-left): Installation phases with completion status
- Progress Pane (middle-right): Real-time progress, status messages, logs
- Input Pane (bottom): User input collection (auto-focus)
State Coordination:
- State files in
/up-state/coordinate between panes update_phase(),update_progress(),read_input()functions- Background installation runs silently in separate tmux window
Packages are categorized by criticality with different failure handling:
- ESSENTIAL: Must succeed - installation aborts on failure
- SYSTEM: Logged failures, installation continues
- SHELL TOOLS: Affects
.zshrcgeneration - COSMETIC: Visual enhancements, optional
- AUR: Requires yay, skipped if yay fails
- Batch First: Attempt group installation for speed
- Fallback to Individual: If batch fails, install packages one-by-one
- Retry Logic: AUR packages use configurable retry attempts
- Graceful Degradation: Optional packages don't block installation
Exit Code Preservation:
_run_command_to_tui() {
tmp_file=$(mktemp)
"$@" > "$tmp_file" 2>&1
local status=$?
# Process output for logging
while IFS= read -r line; do
log_to_console "$line"
done < "$tmp_file"
rm -f "$tmp_file"
return $status
}ANSI Stripping for Tmux:
strip_ansi() {
printf '%s' "$1" | sed 's/\x1b\[[0-9;]*[a-zA-Z]//g'
}Never symlink live configs into the vendor git tree. Layers:
| Layer | Path | Who writes | On up-update |
|---|---|---|---|
| Vendor | /usr/local/share/up |
git only | fetch + reset --hard + clean (local dirt discarded) |
| Stock copies | ~/.config/i3/config, polybar, picom, rofi, … and /etc/lightdm/* |
Up / theme apply | Backup if different, then overwrite from vendor; theme re-applied |
| User intent | ~/.config/up/config, overrides/, keybindings-overrides.toml |
User and menus | Never overwritten |
Hand-edits to stock copies are not sacred: they are saved as *.backup-update-YYYYMMDD (and under /var/lib/up/backups/pre-update-*) then replaced so new product files land. Persistent tweaks belong in the user-intent layer.
Preferences that survive updates live at ~/.config/up/config (TOML):
effects = "auto" # auto | full | lite | safe
fade = true # materialized by compositor profile
blur = true
dim = true
font = "DejaVu Sans Mono"
theme = "aetherweft"
ready_sound = falseCompositor capability (picom):
configs/scripts/detect-compositor-capability.sh— scores virt/GPU/RAM/CPU (optionalglxinfowhenDISPLAYis set)configs/scripts/apply-compositor-profile.sh— writesfade/blur/dim,~/.config/picom/capability.conf, and a cache under~/.config/up/- Session start (
start-session.sh→config-sync.sh) re-applies wheneffects=autoand the machine fingerprint changes; a valid compositor cache skipsglxinfo - Picom includes: main config →
theme.conf→capability.conf(capability wins for backend / hard blur caps)
Live Application:
- Preferred: scripts enqueue directly (
theme/reapply/refresh) — no need to wait for a watcher - config-watcher still runs: only bridges external edits of
~/.config/up/configintosync(no login-time heal sync) desktop-agentdrains the serial queue (compositor → theme files → i3 → polybar → picom)- Session start does early file-only sync (theme rewrite only when
~/.config/up/configchanged); i3exec_alwaysstarts polybar; the agent starts the bar only if it is missing
Loop prevention (watcher ↔ agent):
- Agent sets
watch-suppresswhile it may rewrite~/.config/up/config(fade/theme materialization) - After apply: cool-off window +
config-applied.sha256of the file contents - Watcher uses
desktop_request_from_watch: skip if suppressed, cool-off, same hash as applied, orsyncalready queued
Files that up-update will not replace:
~/.config/up/config # theme, font, effects, ready_sound
~/.config/up/keybindings-overrides.toml # merged into keybindings.conf
~/.config/up/overrides/i3.conf # included last by i3 (extra bindsyms / for_window)
Themes are defined in configs/themes/*.toml with nested sections:
[colors]
background = "#1E1E2E"
foreground = "#CDD6F4"
accent = "#89B4FA"
[alacritty.normal]
black = "#45475A"
red = "#F38BA8"
# ... etc
[i3]
bg = "#1E1E2E"
fg = "#CDD6F4"
accent = "#89B4FA"switch-theme.sh applies themes to all applications:
- i3: Window colors, bar configuration
- Polybar: Colors, fonts, layout
- Alacritty: Terminal colors, cursor
- Rofi: Launcher theme, colors
- GTK: Generated CSS with timestamp rotation for live reload
- Neovim: Dynamic colorscheme generation
- Starship: Prompt colors
- btop/htop: System monitor themes
Shared scripts (switch-theme, apply-compositor-profile, config-sync) run in both places:
| Context | Behavior |
|---|---|
setup.sh (arch-chroot) |
UP_INSTALL=1, --no-reload, --home /home/user — write theme/picom files only; never start desktop-agent |
up-update / migrations / up-add-user |
--home + --no-reload + UP_DESKTOP_INLINE=1 — per-user files only |
start-session.sh (pre-i3) |
UP_DESKTOP_INLINE=1 for config-sync; session curtain fade-in; then i3 starts desktop-agent |
Session curtain: theme/background apply pre-renders JPEG frames (ffmpeg gblur + dim) under ~/.local/state/up/session-curtain/{login,blend,session}/. Login plays the greeter image sharp → blurred. Once i3 IPC and keybindings.conf are present, session-curtain.sh reveal crossfades at blur onto the session wallpaper and unblurs. Optional ready_sound (Kenney CC0) is off by default.
| Graphical session | Theme/font tools enqueue work; agent reloads i3/polybar/picom |
switch-theme refuses the desktop queue when: no DISPLAY, chroot, UP_INSTALL, UP_DESKTOP_INLINE, --home override, or missing agent scripts.
Serial worker so theme, font, compositor, and bar updates never race:
| Piece | Role |
|---|---|
configs/scripts/desktop-agent.sh |
Session daemon; single-instance flock; drains queue |
configs/scripts/desktop-request.sh |
Enqueue API (up-desktop-request) |
| Queue dir | ~/.local/state/up/desktop/queue/*.req |
| Log | ~/.local/state/up/desktop/agent.log |
Request types: theme name=…, reapply, sync [force=1], compositor [force=1], polybar, picom, refresh, boot.
Planning / deduplication:
| Kind | Types | Rule |
|---|---|---|
| Config-changing | theme, reapply, sync, compositor |
Always executed in queue order. Consecutive same type merges params only (theme name last-wins, force OR). Non-consecutive ops both run. |
| Idempotent | polybar, picom, refresh, boot |
Earlier duplicates skipped; only the last of each type in the batch runs (after config steps). |
Batch execution order:
- Each config-changing step (compositor / theme files as planned)
- i3 reload once (if any step needs it)
- polybar restart once
- picom restart once (explicit
picom, or fragments changed)
GTK Applications:
- Theme name rotation with timestamps forces cache invalidation
xsettingsdbroadcasts theme changes- Direct signaling of running GTK processes
Neovim:
- Custom colorschemes generated in
~/.local/share/nvim/site/colors/ - Direct
vim.api.nvim_set_hl()calls for reliable loading - File watchers trigger reload without RPC
Smart fallback hierarchy:
- Theme-specific backgrounds (
configs/backgrounds/{theme}/) - General backgrounds
- Solid color fallback
up-update runs migrations/*.sh once each (marker files under
/var/lib/up/migrations/). New installs already match the current tree except
where a migration also repairs older systems (for example 001-install-cliamp
is a no-op once cliamp is present). See migrations/README.md.
Supported entry point: up-update (System Menu → Update System). ./update.sh is a thin wrapper.
Pipeline (Omarchy-inspired, X11-adapted):
- Confirm + pre-update config backup under
/var/lib/up/backups/ git fetchthenreset --hardto upstream andgit clean -fdon/usr/local/share/up(vendor tree — local edits are discarded, never stash-popped)- Migrations with skip-and-continue option
pacman -Syu(failures reported, not swallowed)- Optional AUR update if yay present
- Diff-aware config refresh + regenerate i3 keybindings
- Re-apply current theme
Single-file helper: up-refresh-config <relative-path>.
Version string: repo root version file.
All output captured to /var/log/up/install.log:
log_message() {
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$timestamp] $*" >> "$ERROR_LOG_FILE"
}Different handling based on package type:
- Essential: Abort installation
- Optional: Log and continue
- AUR: Retry with backoff, then skip
- Rollback: Failed transactions can be rolled back
- State Saving: Installation state persisted for welcome wizard
- Service Tracking: Failed services recorded for post-install fixing
# Good - absolute path guaranteed by installation
/usr/local/share/up/configs/scripts/switch-theme.sh
# Avoid - relative paths that may break
~/.config/up/scripts/switch-theme.sh# Use ${BASH_SOURCE[0]} when script location varies
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"Scripts assume correct installation placement - no fallbacks for corrupted systems.
- Development Machine: Used only for code editing and analysis
- Target System: Where scripts actually execute
- Never execute scripts on development machine - analyze for target system behavior
- Test by inspection: Verify paths, logic work on target system
/usr/local/share/up/ # System installation
├── configs/ # Application configurations
│ ├── scripts/ # Utility scripts
│ ├── themes/ # Theme definitions
│ └── [app]/ # App-specific configs
├── migrations/ # Update scripts
└── bin/ # Executables
~/.config/up/ # User intent (never overwritten)
├── config # Preferences (TOML)
├── keybindings-overrides.toml
└── overrides/
└── i3.conf # Extra i3 lines (included last)
/var/lib/up/ # System state
└── migrations/ # Migration tracking
/var/log/up/ # Logs
└── install.log # Installation log
Multiple processes communicate via filesystem:
- Progress updates via status files
- Input collection via dedicated files
- Phase synchronization across host/chroot
- File watchers monitor config changes
- Immediate application without restarts
- Fallback to manual sync commands
- Optional components fail safely
- Installation continues despite non-critical failures
- Clear logging of what succeeded/failed
- GTK themes generated from color definitions
- Neovim colorschemes created dynamically
- Configuration files templated with user preferences
System menu (up-system-menu / Super+Space):
- Verb-first top level: Apps, Learn, Capture, Style, Setup, Install, Update, Session, System
- Implementation:
configs/scripts/system-menu.sh+rofi-menu.sh+menu-addons.sh - Install offers official packages (
up-pkg-install), AUR (up-pkg-aur-install), extra tools, and remove - Stack-based Back / Escape; actions close the tree
Optional fragments may exist at /usr/local/share/up-addons/*/menu.sh. The OS sources them if present. up-update only git cleans /usr/local/share/up, never sibling directories.
End-user skills ship in default/agents/skills/ (up, diagnose-crash) and are symlinked into ~/.agents/skills and the usual harness skill dirs on install and up-update. The default agent name lives in ~/.config/up/config as agent = "…". up-agent, up-agent-prompt, and up-agent-crash launch it. A user unit up-crash-watch toasts coredumps when an agent is set. Contributor instructions for this git tree are in AGENTS.md, not in the end-user skill.
Rofi/drun (Super+Alt+Space): desktop files under ~/.local/share/applications and /usr/local/share/applications.