diff --git a/.chezmoi.yaml.tmpl b/.chezmoi.yaml.tmpl index b840cc1..94ae392 100644 --- a/.chezmoi.yaml.tmpl +++ b/.chezmoi.yaml.tmpl @@ -62,29 +62,16 @@ data: os_family: {{ $osFamily | quote }} os_id: {{ .chezmoi.osRelease.id | quote }} - # Sway/Wayland desktop stack — enabled per host. Pis don't need it - # (headless); x86_64 desktops do. Override at runtime by creating - # `~/.config/chezmoi/features/sway` (force ON) or - # `~/.config/chezmoi/features/no-sway` (force OFF). + # Sway/Wayland desktop stack — opt-in at bootstrap time. When you + # run `chezmoi init` for the first time, you'll be asked: + # "Install the sway + wofi + foot Wayland desktop stack? [y/N]" + # Answering `y` installs the packages and writes the configs. + # Answering `N` (or pressing enter for default) skips both. # - # To toggle for a new box: `touch ~/.config/chezmoi/features/sway` - # then `chezmoi apply`. - {{- $swayOverrideOn := stat (joinPath .chezmoi.homeDir ".config/chezmoi/features/sway") }} - {{- $swayOverrideOff := stat (joinPath .chezmoi.homeDir ".config/chezmoi/features/no-sway") }} - {{- if $swayOverrideOn }} - sway: true - {{- else if $swayOverrideOff }} - sway: false - {{- else }} - {{- /* Hostname allowlist for the desktop stack. Match if hostname - equals or starts with any of the listed prefixes (e.g. "byte" - matches both "byte" and "byte-arch"). */}} - {{- $swayHosts := list "miche" "byte" "kaiser" }} - {{- $swayMatch := false }} - {{- range $swayHosts }} - {{- if or (eq . $.chezmoi.hostname) (hasPrefix (printf "%s-" .) $.chezmoi.hostname) (hasPrefix (printf "%s." .) $.chezmoi.hostname) }} - {{- $swayMatch = true }} - {{- end }} - {{- end }} - sway: {{ $swayMatch }} - {{- end }} \ No newline at end of file + # To flip later: `touch ~/.config/chezmoi/features/sway` to enable, + # or `touch ~/.config/chezmoi/features/no-sway` to disable, then + # `chezmoi apply`. The marker files override the bootstrap answer. + {{- $swayMarker := not (not (stat (joinPath .chezmoi.homeDir ".config/chezmoi/features/sway"))) }} + {{- $noSwayMarker := not (not (stat (joinPath .chezmoi.homeDir ".config/chezmoi/features/no-sway"))) }} + {{- $swayPrompt := promptBool "sway_setup" false }} + sway_setup: {{ or $swayMarker (and $swayPrompt (not $noSwayMarker)) }} \ No newline at end of file diff --git a/run_once_40-install-sway.sh.tmpl b/run_once_40-install-sway.sh.tmpl index e3000e4..0ab0ada 100644 --- a/run_once_40-install-sway.sh.tmpl +++ b/run_once_40-install-sway.sh.tmpl @@ -16,8 +16,8 @@ set -euo pipefail log() { printf '\033[1;34m[sway]\033[0m %s\n' "$*"; } # --- 0. Gate on the .sway flag --- -{{ if not .sway -}} -log "sway not enabled for this host (.sway=false). Skipping." +{{ 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 -}}