481 lines
22 KiB
Shell
481 lines
22 KiB
Shell
#!/usr/bin/env bash
|
|
# The installer's screens: the original's full-screen TUI (installer/tui) in plain bash, so nothing
|
|
# has to be built first. Steps down the left, the choices on the right, what each one does under
|
|
# them, and keys along the bottom. It only reads the system: choices come back in OPTIONS,
|
|
# SKIP_GROUPS, THEMES_ON and RECOMMENDED, and with --dry-run nothing is run at all.
|
|
|
|
TUI_STEPS=("Welcome" "Apps" "Packages" "Setup" "App colours" "Review" "Install")
|
|
TUI_LEFT=24
|
|
# Off until ticked. With --yes the login screen stays off too (setup.sh).
|
|
TUI_OFF="cjk video"
|
|
declare -A TICK=() DONE_STEP=()
|
|
|
|
# id|what it is called|what it does. Nothing here is forced.
|
|
TUI_OPTIONS=(
|
|
"niri|Keybinds and autostart|Adds caelestia.kdl to your niri config, with a backup. Mod+Space launcher, Mod and the arrows snap windows, Print captures."
|
|
"recommended|Recommended niri settings|Gaps, rounded corners, input, animations. Written once to caelestia-recommended.kdl, yours to edit."
|
|
"terminal|Terminal setup|kitty, fish, fastfetch and the two-line starship prompt, in your scheme's colours. Existing files are kept as .bak-caelestia."
|
|
"portals|Screen sharing and file pickers|xdg-desktop-portal-gnome, about 116 MB as it brings Nautilus, and niri-portals.conf. Without it apps cannot share a screen."
|
|
"keyring|Keyring|gnome-keyring, unlocked at login. Holds Wi-Fi passwords and API keys. Needs sudo for SDDM's PAM file."
|
|
"qt|Qt theming|qt6ct and QT_QPA_PLATFORMTHEME, so Qt apps follow your colours."
|
|
"automount|Automount|udiskie mounts USB drives when you plug them in. Without it use Nexus, Storage."
|
|
"nightlight|Night light|wlsunset, which the shell starts itself when Night Light is on. Without it the toggle only says it is missing."
|
|
"clipboard|Clipboard history|cliphist and wl-clip-persist, which the shell starts itself: Mod+V history, and copies that survive the app closing."
|
|
"video|Video wallpapers|mpvpaper (from the AUR on Arch) and ffmpeg. Without mpvpaper a video wallpaper shows a still frame."
|
|
"cursor|Material cursor|The Material cursor, set as the default. It comes with this installer, nothing to build."
|
|
"login|Login screen|SDDM with the Caelestia lock-like theme, from the AUR. Needs sudo. Replaces your current login theme."
|
|
"loginsync|Keep the login screen in step|Copies your wallpaper and colours to the login screen when they change. Lets its one sync script run as root without a password."
|
|
"monitors|Brightness on desktop monitors|ddcutil, for the OSD's brightness slider on monitors that speak DDC/CI. Laptops do not need it."
|
|
"recording|Screen recording|gpu-screen-recorder and ffmpeg, for Record and GIF in capture."
|
|
"ocr|Text from the screen|tesseract, for copying text out of a capture."
|
|
"annotate|Editing screenshots|satty, opened by the right button in capture."
|
|
"cjk|Chinese, Japanese and Korean fonts|noto-fonts-cjk, about 300 MB. Off unless you read them."
|
|
"tray|X11 tray icons|xembedsniproxy, for Steam and Wine tray icons, from the AUR on Arch, started at login."
|
|
"lock|Lock screen|Installs the caelestia-lock PAM file with sudo. Until one preview passes, the lock is swaylock."
|
|
"cleanup|Remove build tools afterwards|Takes out the compiler if this installer added it, and the build's output. A compiler you already had stays."
|
|
)
|
|
|
|
ROWS=24 COLS=80
|
|
tui_size() {
|
|
read -r ROWS COLS < <(stty size </dev/tty 2>/dev/null || echo "24 80")
|
|
}
|
|
tui_on() {
|
|
# No wrapping: a line too long is cut, not pushed onto the next row.
|
|
printf '\033[?1049h\033[?25l\033[?7l\033[2J' >/dev/tty
|
|
stty -echo </dev/tty 2>/dev/null || true
|
|
trap tui_off EXIT
|
|
}
|
|
tui_off() {
|
|
stty echo </dev/tty 2>/dev/null || true
|
|
printf '\033[?7h\033[?25h\033[?1049l' >/dev/tty
|
|
}
|
|
tui_at() { TUI_BUF+=$(printf '\033[%d;%dH%s' "$1" "$2" "$3"); }
|
|
|
|
# Draws what was built, or asks for room.
|
|
tui_show() {
|
|
if ((COLS < 72 || ROWS < 22)); then
|
|
TUI_BUF=$'\033[2J'
|
|
tui_at 2 3 "${C_ACCENT}${C_BOLD}◆ Caelestia${C_OFF}"
|
|
tui_at 4 3 "${C_TEXT}This window is too small.${C_OFF}"
|
|
tui_at 5 3 "${C_MUTED}It needs 72 by 22, and it is ${COLS} by ${ROWS}.${C_OFF}"
|
|
tui_at 6 3 "${C_MUTED}Make it bigger: this redraws by itself.${C_OFF}"
|
|
fi
|
|
printf '%s' "$TUI_BUF" >/dev/tty
|
|
}
|
|
|
|
# Cuts on a word: tui_wrap <width> <text> sets WRAPPED.
|
|
tui_wrap() {
|
|
local width="$1" line="" word
|
|
WRAPPED=()
|
|
for word in $2; do
|
|
if [[ -n "$line" && $((${#line} + ${#word} + 1)) -gt $width ]]; then
|
|
WRAPPED+=("$line")
|
|
line="$word"
|
|
else
|
|
line="${line:+$line }$word"
|
|
fi
|
|
done
|
|
[[ -z "$line" ]] || WRAPPED+=("$line")
|
|
}
|
|
|
|
# The parts every screen shares: tui_frame <step> <title> <keys>.
|
|
tui_frame() {
|
|
local step="$1" title="$2" keys="$3" i r mark tint
|
|
tui_size
|
|
TUI_BUF=$'\033[2J'
|
|
local right=$((TUI_LEFT + 4)) rule
|
|
printf -v rule '%*s' "$((COLS - 4))" ''
|
|
tui_at 2 3 "${C_ACCENT}${C_BOLD}◆ Caelestia${C_OFF}${C_MUTED} for niri${C_OFF}"
|
|
if [[ "${DRY_RUN:-0}" == 1 ]]; then
|
|
tui_at 2 $((COLS - 22)) "${C_WARN}${C_BOLD} DRY RUN ${C_OFF}${C_MUTED} changes nothing${C_OFF}"
|
|
fi
|
|
tui_at 3 3 "${C_MUTED}${rule// /─}${C_OFF}"
|
|
for i in "${!TUI_STEPS[@]}"; do
|
|
r=$((5 + i * 2))
|
|
if [[ "$i" == "$step" ]]; then
|
|
mark="●" tint="$C_ACCENT$C_BOLD"
|
|
elif [[ -n "${DONE_STEP[$i]:-}" ]]; then
|
|
mark="✓" tint="$C_OK"
|
|
else
|
|
mark="○" tint="$C_MUTED"
|
|
fi
|
|
tui_at "$r" 4 "${tint}${mark} ${TUI_STEPS[$i]}${C_OFF}"
|
|
done
|
|
for ((r = 5; r < ROWS - 2; r++)); do tui_at "$r" $((TUI_LEFT + 1)) "${C_MUTED}│${C_OFF}"; done
|
|
tui_at 5 "$right" "${C_TEXT}${C_BOLD}${title}${C_OFF}"
|
|
tui_at $((ROWS - 2)) 3 "${C_MUTED}${rule// /─}${C_OFF}"
|
|
tui_at $((ROWS - 1)) 4 "${C_MUTED}${keys}${C_OFF}"
|
|
}
|
|
|
|
# Waits for a key. Comes back empty-handed, as KEY=resize, when the window changes size, which
|
|
# a new terminal often does just after it opens.
|
|
tui_key() {
|
|
local rest status old="$ROWS $COLS"
|
|
KEY=""
|
|
while :; do
|
|
status=0
|
|
IFS= read -rsn1 -t 0.15 KEY </dev/tty || status=$?
|
|
if ((status == 0)); then break; fi
|
|
if ((status <= 128)); then
|
|
KEY=q
|
|
return
|
|
fi
|
|
tui_size
|
|
if [[ "$ROWS $COLS" != "$old" ]]; then
|
|
KEY=resize
|
|
return
|
|
fi
|
|
done
|
|
if [[ "$KEY" == $'\033' ]]; then
|
|
IFS= read -rsn2 -t 0.05 rest </dev/tty || true
|
|
KEY+="$rest"
|
|
fi
|
|
}
|
|
|
|
tui_quit() {
|
|
tui_off
|
|
trap - EXIT
|
|
printf '\n %s\n\n' "Left without changing anything."
|
|
exit 0
|
|
}
|
|
|
|
# Choosing: tui_ticks <step> <title> <intro> "id|label|what it does"... Returns 1 for Back.
|
|
# One page of apps as tui_ticks items: None first, then each offer. What is here shows as
|
|
# installed and cannot be changed. An app from Astar Hub whose download does not answer stays
|
|
# listed, unticked, so a slow Hub does not hide it.
|
|
tui_app_page() {
|
|
local page="$1" pkg name cmds dock star any=0 own=0 ownpick=0 pick="" id
|
|
PAGE=("none:$page|None|Install nothing of this kind.")
|
|
while IFS='|' read -r pkg name cmds dock; do
|
|
star=0
|
|
if [[ "$pkg" == \** ]]; then star=1; pkg="${pkg#\*}"; fi
|
|
if app_present "$cmds" || { [[ "$pkg" != @* ]] && package_present "$pkg"; }; then
|
|
PAGE+=("have:$pkg|$name|Already on this system.")
|
|
any=1
|
|
if [[ "$pkg" == @* ]]; then ownpick=1; fi
|
|
elif [[ "$pkg" == @* ]]; then
|
|
# Recommended and ticked only when its download answers.
|
|
if curl -fsI --max-time 8 -o /dev/null "$(own_url "$pkg")" 2>/dev/null; then
|
|
PAGE+=("app:$pkg|$name (recommended)|Made to match this shell. Latest release from Astar Hub.")
|
|
# Only the first own app on a page is ticked, and none once one is here: Mulberry,
|
|
# not Audiphi (user's choice).
|
|
if ((ownpick == 0)); then pick+=" app:$pkg"; fi
|
|
ownpick=1
|
|
own=1
|
|
else
|
|
PAGE+=("app:$pkg|$name (Astar Hub did not answer)|Made to match this shell. Its download did not answer in 8 s; ticked, the install tries again.")
|
|
fi
|
|
else
|
|
local note=""
|
|
# Own apps listed above take the mark; the package is the pick without them.
|
|
if ((star)) && ((own == 0)); then
|
|
note=" (recommended)"
|
|
if ((any == 0)); then pick="app:$pkg"; fi
|
|
fi
|
|
PAGE+=("app:$pkg|$name$note|Installs $pkg.")
|
|
fi
|
|
done < <(app_list "$page")
|
|
# The first time here: the first own app not installed yet, else the recommended package if this kind
|
|
# has nothing yet, otherwise None.
|
|
if [[ -z "${TICK[none:$page]+x}" ]]; then
|
|
for id in $pick; do TICK[$id]=1; done
|
|
if [[ -n "$pick" ]]; then TICK[none:$page]=0; else TICK[none:$page]=1; fi
|
|
fi
|
|
}
|
|
|
|
tui_ticks() {
|
|
local step="$1" title="$2" intro="$3"
|
|
shift 3
|
|
local items=("$@") count=$# at=0 top=0 i r id label desc mark tint
|
|
while :; do
|
|
tui_frame "$step" "$title" "↑↓ move Space tick a all n none Enter next ← back q quit"
|
|
local right=$((TUI_LEFT + 4))
|
|
local width=$((COLS - right - 3))
|
|
tui_at 6 "$right" "${C_MUTED}${intro:0:$width}${C_OFF}"
|
|
local rows=$((ROWS - 15))
|
|
if ((rows < 3)); then rows=3; fi
|
|
if ((at < top)); then top=$at; fi
|
|
if ((at >= top + rows)); then top=$((at - rows + 1)); fi
|
|
for ((i = top; i < count && i < top + rows; i++)); do
|
|
IFS='|' read -r id label desc <<<"${items[$i]}"
|
|
r=$((8 + i - top))
|
|
mark="○" tint="$C_MUTED"
|
|
if [[ "${TICK[$id]:-0}" == 1 ]]; then mark="${C_ACCENT}●${C_OFF}" tint="$C_TEXT"; fi
|
|
if [[ "$id" == have:* ]]; then mark="${C_OK}✓${C_OFF}" tint="$C_MUTED" label+=" installed"; fi
|
|
if ((i == at)); then
|
|
tui_at "$r" "$right" "${C_ACCENT}▌${C_OFF} ${mark} ${C_BOLD}${tint}${label:0:$((width - 4))}${C_OFF}"
|
|
else
|
|
tui_at "$r" "$right" " ${mark} ${tint}${label:0:$((width - 4))}${C_OFF}"
|
|
fi
|
|
done
|
|
if ((count > rows)); then
|
|
tui_at $((8 + rows)) "$right" "${C_MUTED} $((at + 1)) of $count${C_OFF}"
|
|
fi
|
|
IFS='|' read -r id label desc <<<"${items[$at]}"
|
|
tui_wrap "$width" "$desc"
|
|
r=$((ROWS - 6))
|
|
for i in "${!WRAPPED[@]}"; do
|
|
if ((i < 3)); then tui_at $((r + i)) "$right" "${C_PRIMARY}${WRAPPED[$i]}${C_OFF}"; fi
|
|
done
|
|
tui_show
|
|
tui_key
|
|
case "$KEY" in
|
|
$'\033[A'|k) at=$(((at + count - 1) % count)) ;;
|
|
$'\033[B'|j) at=$(((at + 1) % count)) ;;
|
|
' ')
|
|
if [[ "$id" == have:* ]]; then continue; fi
|
|
if [[ "$id" == none:* ]]; then
|
|
for i in "${items[@]}"; do TICK[${i%%|*}]=0; done
|
|
TICK[$id]=1
|
|
elif [[ "${TICK[$id]:-0}" == 1 ]]; then
|
|
TICK[$id]=0
|
|
else
|
|
TICK[$id]=1
|
|
fi
|
|
# On an apps page None means exactly that nothing else is ticked.
|
|
if [[ "${items[0]}" == none:* ]]; then
|
|
local some=0
|
|
for i in "${items[@]:1}"; do
|
|
if [[ "${TICK[${i%%|*}]:-0}" == 1 ]]; then some=1; fi
|
|
done
|
|
TICK[${items[0]%%|*}]=$((!some))
|
|
fi
|
|
;;
|
|
a) if [[ "${items[0]}" != none:* ]]; then for i in "${items[@]}"; do TICK[${i%%|*}]=1; done; fi ;;
|
|
n) for i in "${items[@]}"; do TICK[${i%%|*}]=0; done
|
|
if [[ "${items[0]}" == none:* ]]; then TICK[${items[0]%%|*}]=1; fi ;;
|
|
''|$'\033[C'|l) return 0 ;;
|
|
$'\033[D'|h|b) return 1 ;;
|
|
q) tui_quit ;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
tui_welcome() {
|
|
local lines=("What this does" ""
|
|
" Builds the shell and installs it to ~/.local/bin"
|
|
" Offers what a bare niri lacks, one tick each"
|
|
" Colours your other apps from the wallpaper"
|
|
" Backs up every file it would replace" ""
|
|
"Your distribution: ${BASE_DISTRO:-unknown}"
|
|
"Nothing happens until the Review step.")
|
|
local i
|
|
while :; do
|
|
tui_frame 0 "Welcome" "Enter next q quit"
|
|
local art=(" _____ _ _ _ " " / ____| | | | | (_) " " | | __ _ ___| | ___ ___| |_ _ __ _" " | |___ / _\` |/ _ \\ |/ _ \\/ __| __| |/ _\` |" " \\____|\\__,_|\\___|_|\\___/\\___/\\__|_|\\__,_|")
|
|
if ((COLS > 74 && ROWS > 24)); then
|
|
for i in "${!art[@]}"; do tui_at $((7 + i)) $((TUI_LEFT + 4)) "${C_ACCENT}${art[$i]}${C_OFF}"; done
|
|
fi
|
|
for i in "${!lines[@]}"; do tui_at $((13 + i)) $((TUI_LEFT + 4)) "${C_TEXT}${lines[$i]:0:$((COLS - TUI_LEFT - 7))}${C_OFF}"; done
|
|
tui_show
|
|
tui_key
|
|
case "$KEY" in
|
|
''|$'\033[C'|l) return 0 ;;
|
|
q) tui_quit ;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
# What the choices come to, one "title|detail" a line.
|
|
tui_plan() {
|
|
local group opt id label desc
|
|
local picked
|
|
for id in "${!TICK[@]}"; do
|
|
if [[ "$id" == app:* && "${TICK[$id]}" == 1 ]]; then picked+="${picked:+, }${id#app:}"; fi
|
|
done
|
|
if [[ -n "${picked:-}" ]]; then echo "Install these apps|${picked//@/}"; fi
|
|
if [[ -n "${TUI_GROUPS_ITEMS+x}" ]]; then
|
|
for group in "${TUI_GROUPS_ITEMS[@]}"; do
|
|
IFS='|' read -r id label desc <<<"$group"
|
|
if [[ "${TICK[$id]:-0}" == 1 ]]; then echo "Install: ${label}|${desc#Would install: }"; fi
|
|
done
|
|
fi
|
|
if [[ -x "$BUNDLE_DIR/bin/caelestia-shell" ]]; then
|
|
echo "Install the shell|No compiling: this release has its binaries"
|
|
else
|
|
echo "Build the shell|cargo build --release, then ~/.local/bin and ~/.local/share/caelestia-niri"
|
|
fi
|
|
for opt in "${TUI_OPTIONS[@]}"; do
|
|
IFS='|' read -r id label desc <<<"$opt"
|
|
if [[ "${TICK[$id]:-0}" == 1 ]]; then echo "$label|$desc"; fi
|
|
done
|
|
local themed=""
|
|
if [[ -n "${TUI_THEME_ITEMS+x}" ]]; then
|
|
for opt in "${TUI_THEME_ITEMS[@]}"; do
|
|
IFS='|' read -r id label desc <<<"$opt"
|
|
if [[ "${TICK[$id]:-0}" == 1 ]]; then themed+="${themed:+, }$label"; fi
|
|
done
|
|
fi
|
|
if [[ -n "$themed" ]]; then echo "App colours|$themed"; fi
|
|
}
|
|
|
|
tui_review() {
|
|
local plan top=0 i
|
|
mapfile -t plan < <(tui_plan)
|
|
while :; do
|
|
tui_frame 5 "Review" "↑↓ scroll Enter $([[ "${DRY_RUN:-0}" == 1 ]] && echo 'run the dry run' || echo install) ← back q quit"
|
|
local right=$((TUI_LEFT + 4)) title detail r=7
|
|
local width=$((COLS - right - 3)) rows=$(((ROWS - 10) / 2))
|
|
for ((i = top; i < ${#plan[@]} && i < top + rows; i++)); do
|
|
IFS='|' read -r title detail <<<"${plan[$i]}"
|
|
tui_at "$r" "$right" "${C_OK}✓${C_OFF} ${C_TEXT}${title:0:$((width - 2))}${C_OFF}"
|
|
tui_at $((r + 1)) "$((right + 2))" "${C_MUTED}${detail:0:$((width - 2))}${C_OFF}"
|
|
r=$((r + 2))
|
|
done
|
|
tui_show
|
|
tui_key
|
|
case "$KEY" in
|
|
$'\033[A'|k) if ((top > 0)); then top=$((top - 1)); fi ;;
|
|
$'\033[B'|j) if ((top + rows < ${#plan[@]})); then top=$((top + 1)); fi ;;
|
|
''|$'\033[C'|l) return 0 ;;
|
|
$'\033[D'|h|b) return 1 ;;
|
|
q) tui_quit ;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
# Plays the plan through with nothing behind it, so the last screen can be seen.
|
|
tui_dry_install() {
|
|
local plan i k right=$((TUI_LEFT + 4)) title detail bar filled frames='⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
|
|
mapfile -t plan < <(tui_plan)
|
|
local total=${#plan[@]} rows
|
|
for ((i = 0; i <= total; i++)); do
|
|
for ((k = 0; k < 6; k++)); do
|
|
tui_frame 6 "Install" "Dry run: nothing is being changed"
|
|
local width=$((COLS - right - 3))
|
|
((width > 50)) && bar=50 || bar=$width
|
|
filled=$((bar * i / (total > 0 ? total : 1)))
|
|
printf -v rows '%*s' "$filled" ''
|
|
printf -v detail '%*s' "$((bar - filled))" ''
|
|
tui_at 7 "$right" "${C_ACCENT}${rows// /█}${C_MUTED}${detail// /░}${C_OFF} ${C_TEXT}$((100 * i / (total > 0 ? total : 1)))%${C_OFF}"
|
|
local n r=9 start=$((i > ROWS - 14 ? i - (ROWS - 14) : 0))
|
|
for ((n = start; n < total && n <= i; n++)); do
|
|
IFS='|' read -r title detail <<<"${plan[$n]}"
|
|
if ((n < i)); then
|
|
tui_at "$r" "$right" "${C_OK}✓${C_OFF} ${C_TEXT}would do: ${title:0:$((width - 12))}${C_OFF}"
|
|
else
|
|
tui_at "$r" "$right" "${C_ACCENT}${frames:k:1}${C_OFF} ${C_MUTED}${title:0:$((width - 2))}${C_OFF}"
|
|
fi
|
|
r=$((r + 1))
|
|
done
|
|
tui_show
|
|
if ((i < total)); then sleep 0.06; fi
|
|
done
|
|
done
|
|
DONE_STEP[6]=1
|
|
while :; do
|
|
tui_frame 6 "Done" "q quit r start again"
|
|
tui_at 7 "$right" "${C_OK}${C_BOLD}That was the dry run.${C_OFF}"
|
|
tui_at 9 "$right" "${C_TEXT}Nothing was installed, written or changed.${C_OFF}"
|
|
tui_at 10 "$right" "${C_MUTED}Run ./install.sh without --dry-run to do it for real.${C_OFF}"
|
|
tui_show
|
|
tui_key
|
|
case "$KEY" in
|
|
r) return 1 ;;
|
|
q|'') tui_quit ;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
tui_main() {
|
|
local cli="" group opt id label desc line pkg why
|
|
source "$SCRIPTS_DIR/lib/package-sets.sh"
|
|
source "$SCRIPTS_DIR/lib/apps.sh"
|
|
TUI_GROUPS_ITEMS=()
|
|
local -A names=([BUILD]="Build tools" [DESKTOP]="Desktop plumbing" [SERVICES]="Audio, network, bluetooth, power" [TOOLS]="Tools the shell uses" [THEME]="Fonts, icons and themes")
|
|
for group in BUILD DESKTOP SERVICES TOOLS THEME; do
|
|
local missing=()
|
|
while IFS='|' read -r why pkg; do
|
|
[[ -n "${pkg:-}" ]] || continue
|
|
if [[ "$pkg" =~ ^(rust|cargo)$ ]] && command -v cargo >/dev/null 2>&1; then continue; fi
|
|
package_present "$pkg" || missing+=("$pkg")
|
|
done < <(package_set "$group")
|
|
if ((${#missing[@]})); then
|
|
TUI_GROUPS_ITEMS+=("$group|${names[$group]} (${#missing[@]})|Would install: ${missing[*]}")
|
|
TICK[$group]=1
|
|
fi
|
|
done
|
|
for opt in "${TUI_OPTIONS[@]}"; do TICK[${opt%%|*}]=1; done
|
|
for id in $TUI_OFF; do TICK[$id]=0; done
|
|
if [[ -x "${CAELESTIA_BIN:-$HOME/.local/bin}/caelestia" ]]; then cli="${CAELESTIA_BIN:-$HOME/.local/bin}/caelestia"
|
|
elif [[ -x "$BUNDLE_DIR/bin/caelestia" ]]; then cli="$BUNDLE_DIR/bin/caelestia"
|
|
elif [[ -x "$BUNDLE_DIR/target/release/caelestia" ]]; then cli="$BUNDLE_DIR/target/release/caelestia"; fi
|
|
TUI_THEME_ITEMS=()
|
|
# Without a CLI yet (a checkout not built) the page cannot list: 04 then takes every installed app.
|
|
TUI_THEMES_KNOWN=0
|
|
if [[ -n "$cli" ]]; then
|
|
TUI_THEMES_KNOWN=1
|
|
while IFS= read -r line; do
|
|
line="${line#\[?\] }"
|
|
id="${line%% *}"
|
|
label="$(sed -E 's/^[^ ]+ +//; s/ \((not )?installed\)$//' <<<"$line")"
|
|
case "$id" in enableStarship|enableKitty|enableNiri) continue ;; esac
|
|
if [[ "$line" == *"(installed)"* ]]; then
|
|
TUI_THEME_ITEMS+=("$id|$label|Writes $label's colours each time your scheme changes.")
|
|
TICK[$id]=1
|
|
fi
|
|
done < <("$cli" themes list)
|
|
fi
|
|
tui_on
|
|
local step=0 app_at=0
|
|
while :; do
|
|
case "$step" in
|
|
0) tui_welcome; DONE_STEP[0]=1; step=1 ;;
|
|
1)
|
|
local name="${APP_PAGES[$app_at]}"
|
|
tui_app_page "$name"
|
|
if tui_ticks 1 "Apps: ${APP_TITLE[$name]}" "Page $((app_at + 1)) of ${#APP_PAGES[@]}. Pick any number, or None." "${PAGE[@]}"; then
|
|
if ((app_at + 1 < ${#APP_PAGES[@]})); then
|
|
app_at=$((app_at + 1))
|
|
else
|
|
DONE_STEP[1]=1
|
|
step=2
|
|
fi
|
|
elif ((app_at > 0)); then
|
|
app_at=$((app_at - 1))
|
|
else
|
|
step=0
|
|
fi
|
|
;;
|
|
2)
|
|
if ((${#TUI_GROUPS_ITEMS[@]} == 0)); then DONE_STEP[2]=1; step=3; continue; fi
|
|
if tui_ticks 2 "Packages" "What is missing on this system. Tick what to install." "${TUI_GROUPS_ITEMS[@]}"; then DONE_STEP[2]=1; step=3; else step=1; fi
|
|
;;
|
|
3) if tui_ticks 3 "Setup" "Each is optional. Nexus shows what is installed." "${TUI_OPTIONS[@]}"; then DONE_STEP[3]=1; step=4; else step=2; fi ;;
|
|
4)
|
|
if ((${#TUI_THEME_ITEMS[@]} == 0)); then DONE_STEP[4]=1; step=5; continue; fi
|
|
if tui_ticks 4 "App colours" "Apps found here that can follow your scheme." "${TUI_THEME_ITEMS[@]}"; then DONE_STEP[4]=1; step=5; else step=3; fi
|
|
;;
|
|
5) if tui_review; then DONE_STEP[5]=1; step=6; else step=4; fi ;;
|
|
6)
|
|
if [[ "${DRY_RUN:-0}" == 1 ]]; then
|
|
if ! tui_dry_install; then DONE_STEP=(); step=0; fi
|
|
else
|
|
break
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
tui_off
|
|
trap - EXIT
|
|
OPTIONS="" SKIP_GROUPS="" THEMES_ON="" RECOMMENDED=0 APPS_ON=""
|
|
OWN_ON=""
|
|
for id in "${!TICK[@]}"; do
|
|
if [[ "$id" == app:@* && "${TICK[$id]}" == 1 ]]; then OWN_ON+=" ${id#app:}"
|
|
elif [[ "$id" == app:* && "${TICK[$id]}" == 1 ]]; then APPS_ON+=" ${id#app:}"; fi
|
|
done
|
|
for opt in "${TUI_OPTIONS[@]}"; do
|
|
id="${opt%%|*}"
|
|
if [[ "${TICK[$id]}" == 1 ]]; then OPTIONS+=" $id"; fi
|
|
done
|
|
for group in "${TUI_GROUPS_ITEMS[@]+"${TUI_GROUPS_ITEMS[@]}"}"; do
|
|
id="${group%%|*}"
|
|
if [[ "${TICK[$id]}" != 1 ]]; then SKIP_GROUPS+=" $id"; fi
|
|
done
|
|
for opt in "${TUI_THEME_ITEMS[@]+"${TUI_THEME_ITEMS[@]}"}"; do
|
|
id="${opt%%|*}"
|
|
if [[ "${TICK[$id]}" == 1 ]]; then THEMES_ON+=" $id"; fi
|
|
done
|
|
if [[ "${TICK[recommended]}" == 1 ]]; then RECOMMENDED=1; fi
|
|
export OPTIONS SKIP_GROUPS THEMES_ON RECOMMENDED APPS_ON OWN_ON
|
|
}
|