moonarch/scripts/lib.sh
nevaforget 7d7cbec2ca 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/.
2026-03-29 18:53:57 +02:00

47 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# ABOUTME: Shared helper functions and constants for Moonarch scripts.
# ABOUTME: Sourced by post-install.sh, update.sh and transform.sh.
# Path constants — BASH_SOURCE[1] resolves to the calling script, not lib.sh itself.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[1]}")" && pwd)"
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 ---
log() {
echo -e "\e[1;34m[Moonarch]\e[0m $*"
}
err() {
echo -e "\e[1;31m[Moonarch ERROR]\e[0m $*" >&2
}
read_packages() {
grep -v '^\s*#' "$1" | grep -v '^\s*$'
}
confirm() {
read -r -p "$1 [y/N] " response
[[ "$response" =~ ^[yY]$ ]]
}
# --- Prerequisite checks ---
check_not_root() {
if [[ $EUID -eq 0 ]]; then
err "Do NOT run as root. The script uses sudo where needed."
exit 1
fi
}
check_pacman() {
if ! command -v pacman &>/dev/null; then
err "pacman not found — is this really Arch Linux?"
exit 1
fi
}