feat: add post-install theme switcher (archduino-theme)
Add standalone theme switcher command that lets users change the global colorscheme after installation. Updates Starship, Zellij, Lazygit, and NvChad in one step. Includes `theme` shell alias and README docs.
This commit is contained in:
111
lib/scaffold.sh
111
lib/scaffold.sh
@@ -135,4 +135,113 @@ void loop() {
|
||||
delay(1000);
|
||||
}
|
||||
INO
|
||||
info "Scaffolding tool + templates created"
|
||||
# ── Install theme files + theme switcher ─────────────────────────
|
||||
mkdir -p ~/.config/archduino/themes
|
||||
cp "$SCRIPT_DIR/lib/themes/"*.sh ~/.config/archduino/themes/
|
||||
|
||||
cat >~/.local/bin/archduino-theme <<'SWITCHER'
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
|
||||
info() { echo -e "${GREEN}[✓]${NC} $1"; }
|
||||
warn() { echo -e "${YELLOW}[!]${NC} $1"; }
|
||||
error() { echo -e "${RED}[✗]${NC} $1"; exit 1; }
|
||||
|
||||
THEMES_DIR="$HOME/.config/archduino/themes"
|
||||
THEME_SAVE="$HOME/.config/archduino/theme"
|
||||
|
||||
[[ ! -d "$THEMES_DIR" ]] && error "Theme files not found. Re-run the Archduino installer."
|
||||
|
||||
THEME_FILES=(gruvbox catppuccin tokyonight nord dracula)
|
||||
|
||||
# Load saved theme
|
||||
saved_theme="" current_idx=0
|
||||
if [[ -f "$THEME_SAVE" ]]; then
|
||||
saved_theme=$(cat "$THEME_SAVE")
|
||||
for idx in "${!THEME_FILES[@]}"; do
|
||||
[[ "${THEME_FILES[$idx]}" == "$saved_theme" ]] && current_idx=$((idx + 1)) && break
|
||||
done
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e " ${BOLD}Archduino Theme Switcher${NC}"
|
||||
echo ""
|
||||
|
||||
i=1
|
||||
for t in "${THEME_FILES[@]}"; do
|
||||
source "$THEMES_DIR/$t.sh"
|
||||
if [[ $i -eq $current_idx ]]; then
|
||||
printf " %d) %s ${GREEN}(current)${NC}\n" "$i" "$THEME_DISPLAY_NAME"
|
||||
else
|
||||
printf " %d) %s\n" "$i" "$THEME_DISPLAY_NAME"
|
||||
fi
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
echo ""
|
||||
read -rp " Choice [1-${#THEME_FILES[@]}]: " choice
|
||||
|
||||
if [[ -z "$choice" || ! "$choice" =~ ^[0-9]+$ ]] || ((choice < 1 || choice > ${#THEME_FILES[@]})); then
|
||||
echo " No change."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $choice -eq $current_idx ]]; then
|
||||
echo " Already using that theme."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
selected="${THEME_FILES[$((choice - 1))]}"
|
||||
source "$THEMES_DIR/$selected.sh"
|
||||
|
||||
echo ""
|
||||
info "Applying $THEME_DISPLAY_NAME..."
|
||||
|
||||
# Starship
|
||||
write_starship_config ~/.config/starship.toml
|
||||
info "Starship updated"
|
||||
|
||||
# Zellij
|
||||
write_zellij_config ~/.config/zellij/config.kdl
|
||||
info "Zellij updated"
|
||||
|
||||
# Lazygit
|
||||
write_lazygit_config ~/.config/lazygit/config.yml
|
||||
info "Lazygit updated"
|
||||
|
||||
# NvChad
|
||||
NVIM_CFG="$HOME/.config/nvim"
|
||||
if [[ -f "$NVIM_CFG/lua/chadrc.lua" ]]; then
|
||||
cat >"$NVIM_CFG/lua/chadrc.lua" <<EOF
|
||||
---@type ChadrcConfig
|
||||
local M = {}
|
||||
|
||||
M.base46 = {
|
||||
theme = "$NVCHAD_THEME",
|
||||
}
|
||||
|
||||
return M
|
||||
EOF
|
||||
# Clear theme cache
|
||||
rm -rf ~/.local/share/nvim/lazy/base46/lua/base46/themes 2>/dev/null || true
|
||||
rm -rf ~/.cache/nvim/base46 2>/dev/null || true
|
||||
info "NvChad updated (restart nvim to see changes)"
|
||||
fi
|
||||
|
||||
# Save choice
|
||||
echo "$selected" > "$THEME_SAVE"
|
||||
|
||||
echo ""
|
||||
info "Theme switched to $THEME_DISPLAY_NAME"
|
||||
warn "Restart Zellij and Neovim for full effect."
|
||||
echo ""
|
||||
SWITCHER
|
||||
chmod +x ~/.local/bin/archduino-theme
|
||||
|
||||
info "Scaffolding tool, templates, and theme switcher created"
|
||||
|
||||
Reference in New Issue
Block a user