Replaces the implicit hostname-based enable (miche/byte/kaiser got
sway automatically) with an explicit promptBool asked at first init.
New flow:
1. `chezmoi init` asks: "sway_setup? [y/N]"
2. User says y or N (default N)
3. Answer is captured in data.sway_setup
4. run_once_40-install-sway.sh.tmpl gates on .sway_setup
5. Per-box override via marker files (preserved):
- ~/.config/chezmoi/features/sway → force ON
- ~/.config/chezmoi/features/no-sway → force OFF
Migration for existing boxes:
- Miche/byte/kaiser already have ~/.config/chezmoi/features/sway
marker (from previous hostname-allowlist install) → sway_setup=true
- Rye/crouton have no marker → sway_setup=false (default)
- Both groups pick up the new template on next chezmoi apply
58 lines
No EOL
2 KiB
Bash
58 lines
No EOL
2 KiB
Bash
#!/usr/bin/env bash
|
|
# =============================================================================
|
|
# run_once_40-install-sway.sh.tmpl
|
|
# Install the sway + wofi + foot + supporting tooling desktop stack.
|
|
#
|
|
# Gated on .sway (set in .chezmoi.yaml.tmpl). When false (Pis, headless
|
|
# boxes, etc.), this script exits 0 without doing anything.
|
|
#
|
|
# To opt a new box in: `touch ~/.config/chezmoi/features/sway` then
|
|
# `chezmoi apply`. To opt out: `touch ~/.config/chezmoi/features/no-sway`.
|
|
#
|
|
# Idempotent: skips if sway is already installed.
|
|
# =============================================================================
|
|
set -euo pipefail
|
|
|
|
log() { printf '\033[1;34m[sway]\033[0m %s\n' "$*"; }
|
|
|
|
# --- 0. Gate on the .sway flag ---
|
|
{{ if not .sway_setup -}}
|
|
log "sway_setup not enabled for this host (.sway_setup=false). Skipping."
|
|
log "To enable: touch ~/.config/chezmoi/features/sway && chezmoi apply"
|
|
exit 0
|
|
{{ end -}}
|
|
|
|
# --- 1. Install packages ---
|
|
SWAY_PKGS=(sway wofi foot swaybg swaylock swayidle grim slurp waybar wl-clipboard)
|
|
|
|
{{ if eq .os_family "arch" -}}
|
|
# mako is in arch [extra]
|
|
SWAY_PKGS+=(mako)
|
|
{{ else if eq .os_family "debian" -}}
|
|
# mako isn't packaged on debian. Use dunst (lightweight notification daemon,
|
|
# widely compatible with sway/waybar setups).
|
|
SWAY_PKGS+=(dunst)
|
|
{{ else -}}
|
|
log "WARNING: sway packages not configured for os_family={{ .os_family }}"
|
|
{{ end -}}
|
|
|
|
log "installing sway stack: ${SWAY_PKGS[*]}"
|
|
|
|
{{ if eq .os_family "arch" -}}
|
|
sudo pacman -S --needed --noconfirm "${SWAY_PKGS[@]}"
|
|
{{ else if eq .os_family "debian" -}}
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
sudo apt-get install -y --no-install-recommends "${SWAY_PKGS[@]}"
|
|
{{ end -}}
|
|
|
|
log "sway stack installed"
|
|
sway --version 2>&1 | head -1
|
|
foot --version 2>&1 | head -1
|
|
wofi --version 2>&1 | head -1
|
|
|
|
# --- 2. Mark the box so subsequent chezmoi applies know sway is enabled ---
|
|
mkdir -p ~/.config/chezmoi/features
|
|
touch ~/.config/chezmoi/features/sway
|
|
log "marked box: ~/.config/chezmoi/features/sway"
|
|
|
|
log "sway stack install complete" |