Files
dotfiles/install.sh
T

102 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
set -e
PROFILE_DIR="$(cd "$(dirname "$0")" && pwd)"
PROFILE_NAME="$(basename "$PROFILE_DIR")"
echo "Installing profile: $PROFILE_NAME"
CONFIG_DIRS=(hypr waybar dunst kitty wofi gtk-3.0 gtk-4.0 wal)
# Symlink each config dir (backup real dirs first)
for dir in "${CONFIG_DIRS[@]}"; do
source="$PROFILE_DIR/config/$dir"
target="$HOME/.config/$dir"
[[ ! -d "$source" ]] && continue
if [[ -d "$target" && ! -L "$target" ]]; then
echo " backing up $target -> ${target}.bak"
mv "$target" "${target}.bak"
fi
ln -sfn "$source" "$target"
echo " linked ~/.config/$dir"
done
# Symlink individual config files (for apps where only specific files are tracked)
CONFIG_FILES=(
"VSCodium/User/settings.json:.config/VSCodium/User/settings.json"
)
for entry in "${CONFIG_FILES[@]}"; do
src="${entry%%:*}"
dst="${entry##*:}"
source="$PROFILE_DIR/config/$src"
target="$HOME/$dst"
[[ ! -f "$source" ]] && continue
mkdir -p "$(dirname "$target")"
if [[ -f "$target" && ! -L "$target" ]]; then
echo " backing up $target -> ${target}.bak"
mv "$target" "${target}.bak"
fi
ln -sf "$source" "$target"
echo " linked ~/$dst"
done
# Set active profile
ln -sfn "$PROFILE_DIR" "$HOME/.active_profile"
echo " active profile -> $PROFILE_NAME"
# Set default theme if none is active yet, or active theme is not from this profile
current_theme=$(readlink "$HOME/.active_theme" 2>/dev/null || echo "")
if [[ -z "$current_theme" || ! "$current_theme" == "$PROFILE_DIR/themes/"* ]]; then
default_theme=$(ls "$PROFILE_DIR/themes/" | sort | head -1)
ln -sfn "$PROFILE_DIR/themes/$default_theme" "$HOME/.active_theme"
echo " active theme -> $default_theme"
fi
# Pre-create cache symlinks immediately so Hyprland never sees them missing
# (avoids config errors if Hyprland re-reads its config during the dir swap)
mkdir -p ~/.cache/wal
[[ -f ~/.cache/wal/colors-hypr.conf ]] && ln -sf ~/.cache/wal/colors-hypr.conf ~/.config/hypr/colors.conf
[[ -f ~/.cache/wal/waybar-style.css ]] && ln -sf ~/.cache/wal/waybar-style.css ~/.config/waybar/style.css
[[ -f ~/.cache/wal/wofi-style.css ]] && ln -sf ~/.cache/wal/wofi-style.css ~/.config/wofi/style.css
# Install global scripts to ~/.local/bin
mkdir -p "$HOME/.local/bin"
for script in "$PROFILE_DIR/scripts/"*.sh; do
name=$(basename "$script")
cp "$script" "$HOME/.local/bin/${name%.sh}"
chmod +x "$HOME/.local/bin/${name%.sh}"
echo " installed ~/.local/bin/${name%.sh}"
done
# Make sure ~/.local/bin is in PATH
if ! echo "$PATH" | grep -q "$HOME/.local/bin"; then
echo ""
echo "NOTE: Add ~/.local/bin to your PATH if not already done:"
echo " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.zshrc"
fi
# Load theme
echo ""
echo "Loading theme..."
~/.config/wal/reload.sh
# Restart dunst so new dunstrc and scripts take effect
pkill dunst 2>/dev/null; sleep 0.1; dunst > /dev/null 2>&1 &
disown
echo " restarted dunst"
# Start battery-watch for current session (exec-once handles future logins)
pkill -f battery-watch 2>/dev/null
~/.local/bin/battery-watch > /dev/null 2>&1 &
disown
echo " started battery-watch"
echo ""
echo "Profile '$PROFILE_NAME' installed."
echo ""
echo "To install required packages run:"
echo " sudo pacman -S \$(grep -v '^#' '$PROFILE_DIR/packages.txt' | grep -v '^\s*$' | grep -v '^#.*AUR' | tr '\n' ' ')"
echo " # AUR packages (with yay/paru): see packages.txt"