#!/usr/bin/env bash # Stage 30 — deploy dotfiles into $HOME (backing up whatever was there). source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" log "Deploying dotfiles" require_not_root CFG="${XDG_CONFIG_HOME:-$HOME/.config}" # --- home-level files ------------------------------------------------------ install_file "$DOTFILES_DIR/xinitrc" "$HOME/.xinitrc" 755 install_file "$DOTFILES_DIR/xprofile" "$HOME/.xprofile" 644 install_file "$DOTFILES_DIR/Xresources" "$HOME/.Xresources" 644 install_file "$DOTFILES_DIR/gtkrc-2.0" "$HOME/.gtkrc-2.0" 644 # --- ~/.config/* ----------------------------------------------------------- # Copy each tracked file individually so untracked files the user added # (e.g. their own polybar module) survive a re-run. while IFS= read -r -d '' src; do rel="${src#"$DOTFILES_DIR"/config/}" install_file "$src" "$CFG/$rel" 644 done < <(find "$DOTFILES_DIR/config" -type f -print0) # --- executables ----------------------------------------------------------- step "installing helper scripts to ~/.local/bin" run mkdir -p "$HOME/.local/bin" while IFS= read -r -d '' src; do install_file "$src" "$HOME/.local/bin/$(basename "$src")" 755 done < <(find "$DOTFILES_DIR/local/bin" -type f -print0) # Scripts inside ~/.config need the exec bit too for s in "$CFG/polybar/launch.sh" "$CFG/rofi/scripts/powermenu.sh"; do [[ -f "$s" ]] && run chmod 755 "$s" done if [[ -d "$CFG/i3/scripts" ]]; then run find "$CFG/i3/scripts" -type f -name '*.sh' -exec chmod 755 {} + fi # --- user-owned override directories (never overwritten) ------------------- run mkdir -p "$CFG/i3/config.d" # The include glob in the main config must match at least one file, otherwise # i3 complains on every reload — so ship a comment-only placeholder. if [[ ! -f "$CFG/i3/config.d/00-local.conf" && "$DRY_RUN" != "1" ]]; then cat > "$CFG/i3/config.d/00-local.conf" <<'TXT' # Personal i3 overrides. # # Every *.conf in this directory is included at the very END of # ~/.config/i3/config, so anything you put here wins over the defaults: # re-binding a key here silently replaces the earlier bindsym. # # This directory is never overwritten by the arch-i3 installer. # # Examples: # bindsym $mod+Shift+b exec --no-startup-id firefox # gaps inner 12 # for_window [class="Spotify"] move to workspace $ws9 TXT fi # --- wallpapers ------------------------------------------------------------ step "generating wallpapers" if [[ "$DRY_RUN" == "1" ]]; then skip "would generate wallpapers into $WALLPAPER_DIR" else mkdir -p "$WALLPAPER_DIR" # Prefer any images the user dropped into the repo's wallpapers/ dir shopt -s nullglob repo_walls=("$REPO_ROOT"/wallpapers/*.{png,jpg,jpeg,webp}) shopt -u nullglob if [[ ${#repo_walls[@]} -gt 0 ]]; then cp -n "${repo_walls[@]}" "$WALLPAPER_DIR/" || true ok "copied ${#repo_walls[@]} wallpaper(s) from the repo" fi # Generate the Catppuccin set if the directory is still (nearly) empty if [[ $(find "$WALLPAPER_DIR" -maxdepth 1 -type f | wc -l) -lt 2 ]]; then # pipefail would turn a missing/failing xrandr into a stage abort geom="" if have xrandr; then geom="$(xrandr --query 2>/dev/null | awk '/\*/{print $1; exit}' || true)" fi "$REPO_ROOT/scripts/make-wallpaper.sh" "$WALLPAPER_DIR" "${geom:-2560x1440}" \ || warn "wallpaper generation failed (ImageMagick missing?)" fi fi # --- default applications -------------------------------------------------- step "setting default applications" if [[ "$DRY_RUN" != "1" ]] && have xdg-mime; then xdg-mime default thunar.desktop inode/directory 2>/dev/null || true xdg-settings set default-web-browser firefox.desktop 2>/dev/null || true fi if [[ -d "$BACKUP_DIR" ]]; then warn "previous configs were moved to: $(tildify "$BACKUP_DIR")" fi ok "dotfiles deployed"