112 lines
4.7 KiB
Shell
Executable file
112 lines
4.7 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
# Orchestrates the install, as the original's scripts/setup.sh does, minus everything KDE:
|
|
# prerequisites, build, niri config, app themes. lib/log.sh draws what its C++ TUI drew.
|
|
#
|
|
# install.sh [--dry-run] [--yes] [--themes installed|none|choose] [--no-packages]
|
|
# [--no-niri] [--no-themes] [--no-build]
|
|
#
|
|
# On a terminal it opens the full-screen installer (lib/tui.sh), where each thing is a tick. With
|
|
# --dry-run you go through it all and nothing is changed. With --yes it asks nothing. Everything
|
|
# beyond the shell is optional: the desktop plumbing niri lacks, a terminal setup of kitty, fish,
|
|
# fastfetch and starship, and colours for other apps, which can be changed any time in Nexus.
|
|
|
|
set -euo pipefail
|
|
export CAELESTIA_SETUP_RUNNING=1
|
|
|
|
BUNDLE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
SCRIPTS_DIR="$BUNDLE_DIR/scripts"
|
|
export BUNDLE_DIR
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
|
|
exec 9>"${XDG_RUNTIME_DIR:-/tmp}/caelestia-niri-setup.lock"
|
|
flock -n 9 || { echo "Another Caelestia setup is already running."; exit 1; }
|
|
|
|
source "$SCRIPTS_DIR/lib/log.sh"
|
|
source "$SCRIPTS_DIR/lib/privileges.sh"
|
|
source "$SCRIPTS_DIR/lib/packages.sh"
|
|
source "$SCRIPTS_DIR/lib/selection.sh"
|
|
source "$SCRIPTS_DIR/lib/apps.sh"
|
|
source "$SCRIPTS_DIR/lib/tui.sh"
|
|
|
|
export ASSUME_YES=0 THEMES=ask DRY_RUN=0
|
|
STEPS=(01-ensure-prereqs 02-build-shell 03-niri 04-app-themes 05-extras 06-cleanup)
|
|
skip_step() { STEPS=("${STEPS[@]/$1/}"); }
|
|
|
|
while (($#)); do
|
|
case "$1" in
|
|
-y|--yes) ASSUME_YES=1 ;;
|
|
--dry-run) DRY_RUN=1 ;;
|
|
--themes) THEMES="${2:-}"; shift ;;
|
|
--themes=*) THEMES="${1#*=}" ;;
|
|
--no-packages) skip_step 01-ensure-prereqs ;;
|
|
--no-build) skip_step 02-build-shell ;;
|
|
--no-niri) skip_step 03-niri ;;
|
|
--no-themes) skip_step 04-app-themes ;;
|
|
-h|--help) sed -n '2,11p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
*) die "unknown option $1" ;;
|
|
esac
|
|
shift
|
|
done
|
|
case "$THEMES" in ask|installed|none|choose|list) ;; *) die "--themes takes installed, none or choose" ;; esac
|
|
export THEMES
|
|
|
|
export CAELESTIA_LOG="${XDG_CACHE_HOME:-$HOME/.cache}/caelestia-niri/install.log"
|
|
mkdir -p "$(dirname "$CAELESTIA_LOG")"
|
|
: >"$CAELESTIA_LOG"
|
|
: >"$(dirname "$CAELESTIA_LOG")/failed_packages.txt"
|
|
|
|
declare -A TITLE=(
|
|
[01-ensure-prereqs]="What niri needs"
|
|
[02-build-shell]="Building the shell"
|
|
[03-niri]="Keybinds and autostart"
|
|
[04-app-themes]="Colours in other apps"
|
|
[05-extras]="Your choices"
|
|
[06-cleanup]="Tidying up"
|
|
)
|
|
RUN=()
|
|
for step in "${STEPS[@]}"; do [[ -n "$step" ]] && RUN+=("$step"); done
|
|
|
|
if [[ "$ASSUME_YES" != 1 ]] && [[ -t 0 || -r /dev/tty ]] && { : </dev/tty; } 2>/dev/null; then
|
|
tui_main
|
|
export ASSUME_YES=1 THEMES=list
|
|
[[ "${TUI_THEMES_KNOWN:-1}" == 1 ]] || THEMES=installed
|
|
[[ " $OPTIONS " == *" niri "* ]] || skip_step 03-niri
|
|
RUN=()
|
|
for step in "${STEPS[@]}"; do [[ -n "$step" ]] && RUN+=("$step"); done
|
|
ASKED=1
|
|
elif [[ "$DRY_RUN" == 1 ]]; then
|
|
die "--dry-run needs a terminal to show its screens"
|
|
fi
|
|
# --yes: what the Setup screen ticks by default, without replacing the login screen.
|
|
if [[ -z "${OPTIONS+x}" ]]; then
|
|
OPTIONS=""
|
|
for opt in "${TUI_OPTIONS[@]}"; do
|
|
id="${opt%%|*}"
|
|
[[ " $TUI_OFF login loginsync " == *" $id "* ]] || OPTIONS+=" $id"
|
|
done
|
|
export OPTIONS
|
|
fi
|
|
|
|
ui_banner
|
|
for i in "${!RUN[@]}"; do
|
|
ui_step "$((i + 1))" "${#RUN[@]}" "${TITLE[${RUN[$i]}]}"
|
|
bash "$SCRIPTS_DIR/${RUN[$i]}.sh"
|
|
done
|
|
|
|
ui_step "${#RUN[@]}" "${#RUN[@]}" "Done"
|
|
ok "Start it with: caelestia shell (niri starts it itself after you log in again)"
|
|
info "Print opens screen capture, Mod+Space the launcher, Mod+Comma settings"
|
|
info "Colours: caelestia wallpaper -f <image> or caelestia scheme set -n <name>"
|
|
info "Settings live in ~/.config/niri/caelestia/, the shell's state in ~/.local/state/niri-caelestia/"
|
|
# The lock is swaylock until the shell's own has passed one preview (auth.rs, lock-proved).
|
|
state="${XDG_STATE_HOME:-$HOME/.local/state}"
|
|
if [[ " $OPTIONS " == *" lock "* && ! -e "$state/niri-caelestia/lock-proved" && ! -e "$state/caelestia/lock-proved" ]]; then
|
|
info "The lock is swaylock until you try the shell's own once: caelestia shell lock preview"
|
|
if [[ "${ASKED:-0}" == 1 ]] && pgrep -x caelestia-shell >/dev/null 2>&1; then
|
|
read -r -p " Try the lock now? Type your password to unlock. [y/N] " r </dev/tty || r=""
|
|
if [[ "$r" =~ ^[Yy] ]]; then "${CAELESTIA_BIN:-$HOME/.local/bin}/caelestia" shell lock preview || warn "The preview did not start: try it after you log in again"; fi
|
|
fi
|
|
fi
|
|
failed="${XDG_CACHE_HOME:-$HOME/.cache}/caelestia-niri/failed_packages.txt"
|
|
[[ -s "$failed" ]] && warn "Some packages did not install, listed in $failed"
|
|
info "Full log: $CAELESTIA_LOG"
|