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:
marvin.dietermann
2026-04-10 12:58:22 +02:00
parent 1e5b9a61a0
commit 48f2201a12
4 changed files with 121 additions and 1 deletions

View File

@@ -48,6 +48,14 @@ The installer lets you pick a theme that is applied **consistently** across Neov
| 4 | **Nord** | Arctic, muted blue-grey | | 4 | **Nord** | Arctic, muted blue-grey |
| 5 | **Dracula** | High-contrast purple and green | | 5 | **Dracula** | High-contrast purple and green |
You can **switch themes at any time** after installation:
```bash
archduino-theme # or just: theme
```
This updates Starship, Zellij, Lazygit, and NvChad in one step.
### Supported Boards (out of the box) ### Supported Boards (out of the box)
| Board | FQBN | | Board | FQBN |
@@ -183,6 +191,7 @@ All keybindings are under `<leader>a`:
| `acb` | `arduino-cli board list` | | `acb` | `arduino-cli board list` |
| `lg` | `lazygit` | | `lg` | `lazygit` |
| `v` | `nvim` | | `v` | `nvim` |
| `theme` | `archduino-theme` (switch colorscheme) |
--- ---

View File

@@ -102,6 +102,7 @@ echo " arduino-new my-project uno # scaffold a project"
echo " adev # launch Arduino workspace" echo " adev # launch Arduino workspace"
echo " <leader>av # compile in Neovim" echo " <leader>av # compile in Neovim"
echo " <leader>au # upload in Neovim" echo " <leader>au # upload in Neovim"
echo " theme # switch colorscheme"
echo "" echo ""
warn "A reboot is recommended to apply all changes (shell, groups, PATH)." warn "A reboot is recommended to apply all changes (shell, groups, PATH)."
echo "" echo ""

View File

@@ -135,4 +135,113 @@ void loop() {
delay(1000); delay(1000);
} }
INO 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"

View File

@@ -26,6 +26,7 @@ alias acm="arduino-cli monitor"
alias acb="arduino-cli board list" alias acb="arduino-cli board list"
alias lg="lazygit" alias lg="lazygit"
alias v="nvim" alias v="nvim"
alias theme="archduino-theme"
# ── END ARCHDUINO ───────────────────────────────────────────────' # ── END ARCHDUINO ───────────────────────────────────────────────'
if grep -q "ARCHDUINO CONFIG" ~/.zshrc 2>/dev/null; then if grep -q "ARCHDUINO CONFIG" ~/.zshrc 2>/dev/null; then