Delegate file deployment to moonarch-git package

Refactor post-install.sh and transform.sh to install moonarch-git via
paru instead of manually copying configs, scripts, and themes. Remove
install-themes.sh (replaced by sweet-cursors-git dependency). Replace
update.sh with deprecation notice that forwards to the package-provided
moonarch-update in /usr/bin/.
This commit is contained in:
nevaforget 2026-03-29 18:53:57 +02:00
parent a6a5a709a0
commit 7d7cbec2ca
5 changed files with 91 additions and 420 deletions

View File

@ -1,32 +0,0 @@
#!/bin/bash
# ABOUTME: Installs themes not available via packages (cursor theme).
# ABOUTME: Called by post-install.sh.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
log() {
echo -e "\e[1;34m[Moonarch]\e[0m $*"
}
# --- Sweet-cursors ---
CURSOR_DEST="/usr/share/icons/Sweet-cursors"
if [[ -d "$CURSOR_DEST" ]]; then
log "Sweet-cursors already installed."
else
log "Installing Sweet-cursors..."
TMPDIR=$(mktemp -d)
git clone --depth 1 https://github.com/EliverLara/Sweet.git "$TMPDIR/sweet"
if [[ -d "$TMPDIR/sweet/kde/cursors/Sweet-cursors" ]]; then
sudo cp -r "$TMPDIR/sweet/kde/cursors/Sweet-cursors" "$CURSOR_DEST"
log "Sweet-cursors installed to $CURSOR_DEST."
else
echo "Cursor directory not found in repository." >&2
echo "Please install manually: https://github.com/EliverLara/Sweet" >&2
fi
rm -rf "$TMPDIR"
fi

View File

@ -8,6 +8,7 @@ PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
OFFICIAL_PACKAGES="$PROJECT_DIR/packages/official.txt"
AUR_PACKAGES="$PROJECT_DIR/packages/aur.txt"
DEFAULTS_DIR="$PROJECT_DIR/defaults"
USER_DEFAULTS="/usr/share/moonarch/user-defaults"
# --- Helper functions ---

View File

@ -1,5 +1,5 @@
#!/bin/bash
# ABOUTME: Post-install script for Moonarch — installs packages, defaults and configures the system.
# ABOUTME: Post-install script for Moonarch — installs moonarch-git package and configures the system.
# ABOUTME: Run as regular user after the archinstall base installation.
set -euo pipefail
@ -11,17 +11,6 @@ source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib.sh"
check_not_root
check_pacman
# --- Install official packages ---
log "Installing official packages..."
if [[ -f "$OFFICIAL_PACKAGES" ]]; then
# shellcheck disable=SC2046
sudo pacman -S --needed --noconfirm $(read_packages "$OFFICIAL_PACKAGES")
else
err "Package list not found: $OFFICIAL_PACKAGES"
exit 1
fi
# --- Install paru (AUR Helper) ---
if ! command -v paru &>/dev/null; then
@ -34,17 +23,6 @@ else
log "paru already installed."
fi
# --- Install AUR packages ---
log "Installing AUR packages..."
if [[ -f "$AUR_PACKAGES" ]]; then
# shellcheck disable=SC2046
paru -S --needed --noconfirm $(read_packages "$AUR_PACKAGES")
else
err "AUR package list not found: $AUR_PACKAGES"
exit 1
fi
# --- Set up Moonarch custom paru repo ---
log "Setting up Moonarch paru repo..."
@ -61,39 +39,19 @@ else
fi
paru -Sy --pkgbuilds --noconfirm
paru -S --needed --noconfirm moonset-git moonlock-git moongreet-git
# --- Install themes (cursor etc.) ---
# --- Install moonarch-git (pulls in all configs, scripts, themes as dependencies) ---
log "Installing themes..."
"$SCRIPT_DIR/install-themes.sh"
log "Installing moonarch-git package..."
paru -S --needed --noconfirm moonarch-git
# --- Install XDG defaults ---
log "Installing XDG defaults to /etc/xdg/..."
sudo cp -r "$DEFAULTS_DIR/xdg/"* /etc/xdg/
# Ensure Rofi scripts are executable
sudo find /etc/xdg/rofi -name "*.sh" -exec chmod +x {} \;
# --- GTK4 theme symlinks for libadwaita apps ---
# --- User-level GTK4 symlinks for libadwaita apps ---
THEME_NAME="Colloid-Catppuccin"
THEME_GTK4="/usr/share/themes/$THEME_NAME/gtk-4.0"
GTK4_XDG="/etc/xdg/gtk-4.0"
if [[ -d "$THEME_GTK4" ]]; then
log "Creating system-wide GTK4 symlinks for $THEME_NAME..."
# gtk.css points to gtk-dark.css so libadwaita apps load the dark theme
sudo ln -sf "$THEME_GTK4/gtk-dark.css" "$GTK4_XDG/gtk.css"
sudo ln -sf "$THEME_GTK4/gtk-dark.css" "$GTK4_XDG/gtk-dark.css"
# Assets symlink: remove first if exists (ln -sf on directories follows the link)
sudo rm -f "$GTK4_XDG/assets"
sudo ln -s "$THEME_GTK4/assets" "$GTK4_XDG/assets"
# libadwaita only reads user CSS from ~/.config/gtk-4.0/, not /etc/xdg/ fallback.
# Create per-user symlinks so the theme applies to libadwaita apps (e.g. Nautilus).
log "Creating user-level GTK4 symlinks for $THEME_NAME..."
USER_GTK4="$HOME/.config/gtk-4.0"
mkdir -p "$USER_GTK4"
ln -sf "$THEME_GTK4/gtk-dark.css" "$USER_GTK4/gtk.css"
@ -112,32 +70,32 @@ gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
gsettings set org.gnome.desktop.interface icon-theme 'Colloid-Grey-Catppuccin-Dark'
gsettings set org.gnome.desktop.interface font-name 'UbuntuSans Nerd Font 11'
# --- Install helper scripts ---
# --- Install user config defaults ---
log "Installing Moonarch helper scripts to /usr/local/bin/..."
sudo install -m 755 "$DEFAULTS_DIR/bin/moonarch-"* /usr/local/bin/
# --- awww compatibility symlinks (waypaper still calls swww) ---
if command -v awww &>/dev/null && ! command -v swww &>/dev/null; then
log "Creating swww -> awww compatibility symlinks..."
sudo ln -s /usr/bin/awww /usr/local/bin/swww
sudo ln -s /usr/bin/awww-daemon /usr/local/bin/swww-daemon
log "Installing user config defaults to ~/.config/..."
if [[ -d "$USER_DEFAULTS" ]]; then
# Each subdirectory in user-defaults/ corresponds to a ~/.config/ directory.
# Files are only copied if they don't exist yet (no overwriting).
for src_dir in "$USER_DEFAULTS"/*/; do
app_name="$(basename "$src_dir")"
dest_dir="$HOME/.config/$app_name"
mkdir -p "$dest_dir"
find "$src_dir" -type f -print0 | while IFS= read -r -d '' src_file; do
rel_path="${src_file#"$src_dir"}"
dest_file="$dest_dir/$rel_path"
if [[ ! -f "$dest_file" ]]; then
mkdir -p "$(dirname "$dest_file")"
cp "$src_file" "$dest_file"
log " + $app_name/$rel_path"
else
log " ~ $app_name/$rel_path already exists, skipped."
fi
done
done
fi
# --- Zsh configuration ---
# --- Zsh user config ---
log "Installing Zsh default config..."
sudo cp "$DEFAULTS_DIR/shell/zshrc" /etc/zsh/zshrc.moonarch
# Entry in /etc/zsh/zshrc to load Moonarch defaults
# unless the user has their own ~/.zshrc
if ! grep -q "zshrc.moonarch" /etc/zsh/zshrc 2>/dev/null; then
echo '# Moonarch defaults (overridden by ~/.zshrc)' | sudo tee -a /etc/zsh/zshrc > /dev/null
echo '[[ ! -f "$HOME/.zshrc" ]] && source /etc/zsh/zshrc.moonarch' | sudo tee -a /etc/zsh/zshrc > /dev/null
fi
# If user has no .zshrc yet, link Moonarch defaults
if [[ ! -f "$HOME/.zshrc" ]]; then
log "No ~/.zshrc found — sourcing Moonarch defaults."
mkdir -p "$HOME/.zshrc.d"
@ -145,18 +103,21 @@ if [[ ! -f "$HOME/.zshrc" ]]; then
echo "source /etc/zsh/zshrc.moonarch" >> "$HOME/.zshrc"
fi
# --- greetd / moongreet configuration ---
# --- Enable systemd user services ---
log "Configuring greetd + moongreet..."
sudo mkdir -p /etc/greetd
sudo cp "$DEFAULTS_DIR/etc/greetd/config.toml" /etc/greetd/config.toml
sudo mkdir -p /etc/moongreet
sudo cp "$DEFAULTS_DIR/etc/moongreet/moongreet.toml" /etc/moongreet/moongreet.toml
log "Enabling systemd user services..."
USER_SERVICES=(
"kanshi"
)
# Install default wallpaper (greeter, lockscreen, desktop)
log "Installing default wallpaper..."
sudo mkdir -p /usr/share/moonarch
sudo cp "$DEFAULTS_DIR/backgrounds/wallpaper.jpg" /usr/share/moonarch/wallpaper.jpg
for service in "${USER_SERVICES[@]}"; do
if systemctl --user list-unit-files "${service}.service" &>/dev/null; then
systemctl --user enable "$service"
log " + $service (user)"
else
log " ~ $service (user) not found, skipped."
fi
done
# --- Enable systemd services ---
@ -201,57 +162,11 @@ if ! groups | grep -q docker; then
sudo usermod -aG docker "$USER"
fi
# --- Install user config defaults ---
log "Installing user config defaults to ~/.config/..."
USER_DEFAULTS_DIR="$DEFAULTS_DIR/user"
if [[ -d "$USER_DEFAULTS_DIR" ]]; then
# Each subdirectory in defaults/user/ corresponds to a ~/.config/ directory.
# Files are only copied if they don't exist yet (no overwriting).
for src_dir in "$USER_DEFAULTS_DIR"/*/; do
app_name="$(basename "$src_dir")"
dest_dir="$HOME/.config/$app_name"
mkdir -p "$dest_dir"
find "$src_dir" -type f -print0 | while IFS= read -r -d '' src_file; do
rel_path="${src_file#"$src_dir"}"
dest_file="$dest_dir/$rel_path"
if [[ ! -f "$dest_file" ]]; then
mkdir -p "$(dirname "$dest_file")"
cp "$src_file" "$dest_file"
log " + $app_name/$rel_path"
else
log " ~ $app_name/$rel_path already exists, skipped."
fi
done
done
fi
# --- Enable systemd user services ---
log "Enabling systemd user services..."
USER_SERVICES=(
"kanshi"
)
for service in "${USER_SERVICES[@]}"; do
if systemctl --user list-unit-files "${service}.service" &>/dev/null; then
systemctl --user enable "$service"
log " + $service (user)"
else
log " ~ $service (user) not found, skipped."
fi
done
# --- Screenshots directory ---
mkdir -p "$HOME/Pictures/Screenshots"
mkdir -p "$HOME/Pictures/Wallpaper"
# --- moonarch-update Symlink ---
log "Creating moonarch-update command..."
sudo ln -sf "$PROJECT_DIR/scripts/update.sh" /usr/local/bin/moonarch-update
# --- Done ---
log ""

View File

@ -1,6 +1,6 @@
#!/bin/bash
# ABOUTME: Transforms an existing Arch+Wayland system into a Moonarch system.
# ABOUTME: Backs up configs, installs packages, deploys all defaults with hard overwrite.
# ABOUTME: Backs up configs, installs moonarch-git package, deploys user configs with hard overwrite.
set -euo pipefail
@ -73,11 +73,10 @@ fi
echo ""
log "Actions:"
log " 1. Backup ~/.config/, ~/.zshrc, /etc/xdg/ to ~/moonarch-backup-<ts>.tar.gz"
log " 2. Install official + AUR packages"
log " 2. Install moonarch-git package (pulls in all dependencies)"
log " 3. Disable conflicting DMs, enable greetd"
log " 4. Overwrite ALL system configs (/etc/xdg/, /etc/greetd/, ...)"
log " 5. Overwrite ALL user configs (~/.config/)"
log " 6. Configure zsh, GTK themes, firewall, services"
log " 4. Overwrite ALL user configs (~/.config/)"
log " 5. Configure GTK themes, firewall, services"
echo ""
# Show package diff
@ -119,7 +118,7 @@ for src_dir in "$DEFAULTS_DIR/xdg/"*/; do
done
for bin in "$DEFAULTS_DIR/bin/moonarch-"*; do
name=$(basename "$bin")
if ! cmp -s "$bin" "/usr/local/bin/$name" 2>/dev/null; then
if ! cmp -s "$bin" "/usr/bin/$name" 2>/dev/null; then
((CHANGED_BIN++)) || true
fi
done
@ -189,18 +188,9 @@ if pacman -Qq pulseaudio &>/dev/null; then
fi
# ============================================================
# Phase 6: Install Packages
# Phase 6: Install moonarch-git Package
# ============================================================
log "Installing official packages..."
if [[ -f "$OFFICIAL_PACKAGES" ]]; then
# shellcheck disable=SC2046
sudo pacman -S --needed --noconfirm $(read_packages "$OFFICIAL_PACKAGES")
else
err "Package list not found: $OFFICIAL_PACKAGES"
exit 1
fi
# Install paru if not present
if ! command -v paru &>/dev/null; then
log "Installing paru..."
@ -212,15 +202,6 @@ else
log "paru already installed."
fi
log "Installing AUR packages..."
if [[ -f "$AUR_PACKAGES" ]]; then
# shellcheck disable=SC2046
paru -S --needed --noconfirm $(read_packages "$AUR_PACKAGES")
else
err "AUR package list not found: $AUR_PACKAGES"
exit 1
fi
# Moonarch custom paru repo
log "Setting up Moonarch paru repo..."
PARU_CONF="$HOME/.config/paru/paru.conf"
@ -236,33 +217,20 @@ else
fi
paru -Sy --pkgbuilds --noconfirm
paru -S --needed --noconfirm moonset-git moonlock-git moongreet-git
# Themes
log "Installing themes..."
"$SCRIPT_DIR/install-themes.sh"
log "Installing moonarch-git package..."
paru -S --needed --noconfirm moonarch-git
# ============================================================
# Phase 7: Deploy System Configs (Hard Overwrite)
# Phase 7: User-Level Configuration
# ============================================================
log "Deploying XDG defaults to /etc/xdg/..."
sudo cp -r "$DEFAULTS_DIR/xdg/"* /etc/xdg/
sudo find /etc/xdg/rofi -name "*.sh" -exec chmod +x {} \;
# GTK4 theme symlinks
# User-level GTK4 symlinks for libadwaita apps
THEME_NAME="Colloid-Catppuccin"
THEME_GTK4="/usr/share/themes/$THEME_NAME/gtk-4.0"
GTK4_XDG="/etc/xdg/gtk-4.0"
if [[ -d "$THEME_GTK4" ]]; then
log "Creating system-wide GTK4 symlinks for $THEME_NAME..."
sudo ln -sf "$THEME_GTK4/gtk-dark.css" "$GTK4_XDG/gtk.css"
sudo ln -sf "$THEME_GTK4/gtk-dark.css" "$GTK4_XDG/gtk-dark.css"
sudo rm -f "$GTK4_XDG/assets"
sudo ln -s "$THEME_GTK4/assets" "$GTK4_XDG/assets"
# libadwaita only reads user CSS from ~/.config/gtk-4.0/
log "Creating user-level GTK4 symlinks for $THEME_NAME..."
USER_GTK4="$HOME/.config/gtk-4.0"
mkdir -p "$USER_GTK4"
ln -sf "$THEME_GTK4/gtk-dark.css" "$USER_GTK4/gtk.css"
@ -280,58 +248,17 @@ gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
gsettings set org.gnome.desktop.interface icon-theme 'Colloid-Grey-Catppuccin-Dark'
gsettings set org.gnome.desktop.interface font-name 'UbuntuSans Nerd Font 11'
# Helper scripts
log "Installing Moonarch helper scripts to /usr/local/bin/..."
sudo install -m 755 "$DEFAULTS_DIR/bin/moonarch-"* /usr/local/bin/
# awww compatibility symlinks
if command -v awww &>/dev/null && ! command -v swww &>/dev/null; then
log "Creating swww -> awww compatibility symlinks..."
sudo ln -s /usr/bin/awww /usr/local/bin/swww
sudo ln -s /usr/bin/awww-daemon /usr/local/bin/swww-daemon
fi
# Zsh configuration
log "Installing Zsh default config..."
sudo cp "$DEFAULTS_DIR/shell/zshrc" /etc/zsh/zshrc.moonarch
if ! grep -q "zshrc.moonarch" /etc/zsh/zshrc 2>/dev/null; then
echo '# Moonarch defaults (overridden by ~/.zshrc)' | sudo tee -a /etc/zsh/zshrc > /dev/null
echo '[[ ! -f "$HOME/.zshrc" ]] && source /etc/zsh/zshrc.moonarch' | sudo tee -a /etc/zsh/zshrc > /dev/null
fi
# For transform: always create a fresh .zshrc that sources Moonarch defaults
log "Creating ~/.zshrc with Moonarch defaults..."
mkdir -p "$HOME/.zshrc.d"
echo "# Load Moonarch defaults, add custom overrides in ~/.zshrc.d/ or below" > "$HOME/.zshrc"
echo "source /etc/zsh/zshrc.moonarch" >> "$HOME/.zshrc"
# greetd / moongreet
log "Configuring greetd + moongreet..."
sudo mkdir -p /etc/greetd
sudo cp "$DEFAULTS_DIR/etc/greetd/config.toml" /etc/greetd/config.toml
sudo mkdir -p /etc/moongreet
sudo cp "$DEFAULTS_DIR/etc/moongreet/moongreet.toml" /etc/moongreet/moongreet.toml
# Niri greeter config (if present)
if [[ -f "$DEFAULTS_DIR/etc/greetd/niri-greeter.kdl" ]]; then
sudo cp "$DEFAULTS_DIR/etc/greetd/niri-greeter.kdl" /etc/greetd/niri-greeter.kdl
fi
# Wallpaper
log "Installing default wallpaper..."
sudo mkdir -p /usr/share/moonarch
sudo cp "$DEFAULTS_DIR/backgrounds/wallpaper.jpg" /usr/share/moonarch/wallpaper.jpg
# ============================================================
# Phase 8: Deploy User Configs (Hard Overwrite)
# ============================================================
# Replace user-level XDG configs for all apps Moonarch manages
# Replace user-level XDG configs from /etc/xdg/ (deployed by moonarch-git)
log "Deploying XDG configs to ~/.config/ (overwrite)..."
for src_dir in "$DEFAULTS_DIR/xdg/"*/; do
for src_dir in /etc/xdg/*/; do
app_name="$(basename "$src_dir")"
# gtk-4.0 is handled separately with Colloid-Catppuccin theme symlinks (Phase 7)
# Only overwrite apps that moonarch manages
[[ -d "$DEFAULTS_DIR/xdg/$app_name" ]] || continue
# gtk-4.0 is handled separately with Colloid-Catppuccin theme symlinks
[[ "$app_name" == "gtk-4.0" ]] && continue
dest_dir="$HOME/.config/$app_name"
rm -rf "$dest_dir"
@ -341,9 +268,8 @@ done
# Deploy user defaults (overwrite, no existence check)
log "Deploying user config defaults to ~/.config/ (overwrite)..."
USER_DEFAULTS_DIR="$DEFAULTS_DIR/user"
if [[ -d "$USER_DEFAULTS_DIR" ]]; then
for src_dir in "$USER_DEFAULTS_DIR"/*/; do
if [[ -d "$USER_DEFAULTS" ]]; then
for src_dir in "$USER_DEFAULTS"/*/; do
app_name="$(basename "$src_dir")"
dest_dir="$HOME/.config/$app_name"
mkdir -p "$dest_dir"
@ -357,10 +283,31 @@ if [[ -d "$USER_DEFAULTS_DIR" ]]; then
done
fi
# Zsh: always create a fresh .zshrc that sources Moonarch defaults
log "Creating ~/.zshrc with Moonarch defaults..."
mkdir -p "$HOME/.zshrc.d"
echo "# Load Moonarch defaults, add custom overrides in ~/.zshrc.d/ or below" > "$HOME/.zshrc"
echo "source /etc/zsh/zshrc.moonarch" >> "$HOME/.zshrc"
# ============================================================
# Phase 9: Services & Finalization
# ============================================================
# Enable systemd user services
log "Enabling systemd user services..."
USER_SERVICES=(
"kanshi"
)
for service in "${USER_SERVICES[@]}"; do
if systemctl --user list-unit-files "${service}.service" &>/dev/null; then
systemctl --user enable "$service"
log " + $service (user)"
else
log " ~ $service (user) not found, skipped."
fi
done
log "Enabling services..."
SERVICES=(
"NetworkManager"
@ -403,10 +350,6 @@ fi
mkdir -p "$HOME/Pictures/Screenshots"
mkdir -p "$HOME/Pictures/Wallpaper"
# moonarch-update symlink
log "Creating moonarch-update command..."
sudo ln -sf "$PROJECT_DIR/scripts/update.sh" /usr/local/bin/moonarch-update
# ============================================================
# Phase 10: Done
# ============================================================

View File

@ -1,170 +1,14 @@
#!/bin/bash
# ABOUTME: Moonarch system updater — updates system, repo and defaults.
# ABOUTME: Should be run regularly to keep the system in sync.
# ABOUTME: Legacy updater — replaced by moonarch-update from the moonarch-git package.
# ABOUTME: Prints deprecation notice and forwards if package version is available.
set -euo pipefail
echo ""
echo -e "\e[1;33m[Moonarch]\e[0m moonarch-update is now provided by the moonarch-git package."
echo -e "\e[1;33m[Moonarch]\e[0m Install with: paru -S moonarch-git"
echo -e "\e[1;33m[Moonarch]\e[0m Then run: moonarch-update"
echo ""
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib.sh"
# --- Prerequisites ---
check_not_root
# --- 1. Update Moonarch repo ---
log "=== Update Moonarch repo ==="
cd "$PROJECT_DIR"
if sudo git rev-parse --is-inside-work-tree &>/dev/null; then
LOCAL=$(sudo git rev-parse HEAD)
sudo git fetch origin
REMOTE=$(sudo git rev-parse @{u} 2>/dev/null || echo "$LOCAL")
if [[ "$LOCAL" != "$REMOTE" ]]; then
log "Updates available."
sudo git --no-pager log --oneline "$LOCAL".."$REMOTE"
echo ""
if confirm "Update repo?"; then
sudo git pull --ff-only
log "Repo updated."
else
log "Repo update skipped."
fi
else
log "Repo is up to date."
fi
else
log "Not a git repo — repo update skipped."
if command -v moonarch-update &>/dev/null && [[ "$(which moonarch-update)" == "/usr/bin/moonarch-update" ]]; then
echo -e "\e[1;34m[Moonarch]\e[0m Package version detected. Forwarding..."
exec moonarch-update
fi
# --- 2. Update system packages ---
log "=== Update system packages ==="
if confirm "Run pacman -Syu?"; then
sudo pacman -Syu
else
log "System update skipped."
fi
if command -v paru &>/dev/null; then
if confirm "Update AUR packages (paru -Sua)?"; then
paru -Sua
else
log "AUR update skipped."
fi
fi
# --- 3. Install missing packages ---
log "=== Reconcile package lists ==="
if [[ -f "$OFFICIAL_PACKAGES" ]]; then
MISSING_OFFICIAL=$(comm -23 <(read_packages "$OFFICIAL_PACKAGES" | sort) <(pacman -Qqe | sort) || true)
if [[ -n "$MISSING_OFFICIAL" ]]; then
log "Missing official packages:"
echo "$MISSING_OFFICIAL"
if confirm "Install?"; then
# shellcheck disable=SC2086
sudo pacman -S --needed --noconfirm $MISSING_OFFICIAL
fi
else
log "All official packages installed."
fi
fi
if [[ -f "$AUR_PACKAGES" ]] && command -v paru &>/dev/null; then
MISSING_AUR=$(comm -23 <(read_packages "$AUR_PACKAGES" | sort) <(pacman -Qqe | sort) || true)
if [[ -n "$MISSING_AUR" ]]; then
log "Missing AUR packages:"
echo "$MISSING_AUR"
if confirm "Install?"; then
# shellcheck disable=SC2086
paru -S --needed --noconfirm $MISSING_AUR
fi
else
log "All AUR packages installed."
fi
fi
# --- 4. Update defaults ---
log "=== Update defaults ==="
# XDG Defaults
CHANGED_XDG=false
if ! diff -rq "$DEFAULTS_DIR/xdg/" /etc/xdg/ --exclude='*.pyc' &>/dev/null 2>&1; then
CHANGED_XDG=true
fi
if $CHANGED_XDG; then
log "XDG defaults have changed."
diff -rq "$DEFAULTS_DIR/xdg/" /etc/xdg/ --exclude='*.pyc' 2>/dev/null | head -20 || true
echo ""
if confirm "Deploy XDG defaults to /etc/xdg/?"; then
sudo cp -r "$DEFAULTS_DIR/xdg/"* /etc/xdg/
log "XDG defaults updated."
fi
else
log "XDG defaults are up to date."
fi
# Binaries
CHANGED_BIN=false
for bin in "$DEFAULTS_DIR/bin/moonarch-"*; do
name=$(basename "$bin")
if ! cmp -s "$bin" "/usr/local/bin/$name" 2>/dev/null; then
CHANGED_BIN=true
break
fi
done
if $CHANGED_BIN; then
log "Moonarch binaries have changed."
for bin in "$DEFAULTS_DIR/bin/moonarch-"*; do
name=$(basename "$bin")
if ! cmp -s "$bin" "/usr/local/bin/$name" 2>/dev/null; then
log " ~ $name"
fi
done
if confirm "Deploy binaries to /usr/local/bin/?"; then
sudo install -m 755 "$DEFAULTS_DIR/bin/moonarch-"* /usr/local/bin/
log "Binaries updated."
fi
else
log "Binaries are up to date."
fi
# Zsh
if ! cmp -s "$DEFAULTS_DIR/shell/zshrc" /etc/zsh/zshrc.moonarch 2>/dev/null; then
log "Zsh defaults have changed."
if confirm "Update Zsh defaults?"; then
sudo cp "$DEFAULTS_DIR/shell/zshrc" /etc/zsh/zshrc.moonarch
log "Zsh defaults updated."
fi
else
log "Zsh defaults are up to date."
fi
# --- 5. Orphaned packages ---
log "=== Orphaned packages ==="
ORPHANS=$(pacman -Qdtq 2>/dev/null || true)
if [[ -n "$ORPHANS" ]]; then
log "Orphaned packages found:"
echo "$ORPHANS"
if confirm "Remove?"; then
# shellcheck disable=SC2086
sudo pacman -Rsn --noconfirm $ORPHANS
fi
else
log "No orphaned packages."
fi
# --- Done ---
log ""
log "============================================"
log " Moonarch update complete!"
log "============================================"