#!/usr/bin/env bash # install.sh — bootstrap dotfiles on a fresh Arch/CachyOS install # Usage: ./install.sh [--dry-run] set -euo pipefail DOTFILES="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DRY_RUN=false [[ "${1:-}" == "--dry-run" ]] && DRY_RUN=true # ------------------------------------------------------- # Helpers # ------------------------------------------------------- info() { echo -e "\e[34m[INFO]\e[0m $*"; } ok() { echo -e "\e[32m[ OK ]\e[0m $*"; } warn() { echo -e "\e[33m[WARN]\e[0m $*"; } error() { echo -e "\e[31m[ERR ]\e[0m $*"; } dry() { echo -e "\e[90m[DRY ]\e[0m $*"; } run() { if $DRY_RUN; then dry "$*" else "$@" fi } # ------------------------------------------------------- # 1. Check: Wayland / Hyprland environment # ------------------------------------------------------- info "Checking display server..." if [[ -z "${WAYLAND_DISPLAY:-}" && -z "${XDG_SESSION_TYPE:-}" ]]; then warn "WAYLAND_DISPLAY not set — are you running a Wayland session?" elif [[ "${XDG_SESSION_TYPE:-}" == "x11" ]]; then warn "Session type is X11. Hyprland and Waybar require Wayland." else ok "Wayland session detected (${XDG_SESSION_TYPE:-wayland})" fi # ------------------------------------------------------- # 2. Check: Required programs # ------------------------------------------------------- info "Checking required programs..." REQUIRED=( hyprland waybar hyprpaper alacritty grim slurp swappy wl-copy wofi thunar btop nm-connection-editor kdeconnect-indicator expac pavucontrol notify-send ) MISSING=() for cmd in "${REQUIRED[@]}"; do if command -v "$cmd" &>/dev/null; then ok " $cmd" else warn " $cmd — NOT FOUND" MISSING+=("$cmd") fi done if [[ ${#MISSING[@]} -gt 0 ]]; then warn "Missing programs: ${MISSING[*]}" read -rp "Install missing packages with yay now? [y/N] " ans if [[ "${ans,,}" == "y" ]]; then run yay -S --needed "${MISSING[@]}" else warn "Skipping package install — some features may not work." fi else ok "All required programs found." fi # ------------------------------------------------------- # 3. Check: Required fonts # ------------------------------------------------------- info "Checking fonts..." FONTS=( ttf-sourcecodepro-nerd ttf-nerd-fonts-symbols ttf-nerd-fonts-symbols-mono otf-font-awesome ) MISSING_FONTS=() for pkg in "${FONTS[@]}"; do if pacman -Q "$pkg" &>/dev/null; then ok " $pkg" else warn " $pkg — NOT INSTALLED" MISSING_FONTS+=("$pkg") fi done if [[ ${#MISSING_FONTS[@]} -gt 0 ]]; then read -rp "Install missing fonts with yay now? [y/N] " ans if [[ "${ans,,}" == "y" ]]; then run yay -S --needed "${MISSING_FONTS[@]}" run fc-cache -fv else warn "Skipping font install — icons in Waybar may not render." fi else ok "All required fonts installed." fi # ------------------------------------------------------- # 4. Symlinks # ------------------------------------------------------- info "Creating symlinks..." symlink() { local src="$1" local dst="$2" local parent parent="$(dirname "$dst")" if [[ ! -e "$src" ]]; then error "Source does not exist: $src — skipping" return fi run mkdir -p "$parent" if [[ -L "$dst" ]]; then local current current="$(readlink "$dst")" if [[ "$current" == "$src" ]]; then ok " $dst (already linked)" return else warn " $dst points elsewhere ($current) — relinking" run ln -sfn "$src" "$dst" fi elif [[ -e "$dst" ]]; then local bak="${dst}.bak.$(date +%Y%m%d_%H%M%S)" warn " $dst exists — backing up to $bak" run mv "$dst" "$bak" run ln -s "$src" "$dst" else run ln -s "$src" "$dst" ok " $dst → $src" fi } symlink "$DOTFILES/.bashrc" "$HOME/.bashrc" symlink "$DOTFILES/.config/hypr" "$HOME/.config/hypr" symlink "$DOTFILES/.config/waybar" "$HOME/.config/waybar" symlink "$DOTFILES/.config/alacritty" "$HOME/.config/alacritty" symlink "$DOTFILES/.local/bin/waybar" "$HOME/.local/bin/waybar" # Ensure waybar scripts are executable if [[ -d "$DOTFILES/.config/waybar/scripts" ]]; then run chmod +x "$DOTFILES/.config/waybar/scripts/"*.sh ok "Waybar scripts marked executable" fi # ------------------------------------------------------- # 5. Check: NAS mount points # ------------------------------------------------------- info "Checking NAS mount points..." for mnt in /mnt/data /mnt/usb1; do if mountpoint -q "$mnt" 2>/dev/null; then ok " $mnt is mounted" elif [[ -d "$mnt" ]]; then warn " $mnt exists but is not mounted" else warn " $mnt does not exist — Waybar mount checks will show unmounted" run sudo mkdir -p "$mnt" fi done # ------------------------------------------------------- # Done # ------------------------------------------------------- echo "" ok "Dotfiles installed! Start a new shell or run: source ~/.bashrc" if command -v hyprland &>/dev/null; then ok "Log out and back in to start Hyprland with Waybar." fi