Includes modular setup, device profile support, and documentation. 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode <noreply@opencode.ai>
70 lines
2.5 KiB
Bash
Executable File
70 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Ensure required directories exist
|
|
mkdir -p "$HOME/.config"
|
|
|
|
echo "Symlinking dotfiles..."
|
|
# Get the dotfiles directory (parent of modules directory)
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
DOTFILES_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
# Symlink regular dotfiles (excluding .config directory)
|
|
for file in $(find "$DOTFILES_DIR" -maxdepth 1 -name ".*"); do
|
|
[ "$file" = "$DOTFILES_DIR/.git" ] && continue
|
|
[ "$file" = "$DOTFILES_DIR/.github" ] && continue
|
|
[ "$file" = "$DOTFILES_DIR/.vscode" ] && continue
|
|
[ "$file" = "$DOTFILES_DIR/.config" ] && continue # Handle .config separately
|
|
basefile="$(basename "$file")"
|
|
if [ -f "$file" ] || [ -d "$file" ]; then
|
|
ln -sf "$file" "$HOME/$basefile"
|
|
echo "Linked $basefile"
|
|
fi
|
|
done
|
|
|
|
# Symlink .config directory contents
|
|
CONFIG_DIR="$DOTFILES_DIR/.config"
|
|
if [ -d "$CONFIG_DIR" ]; then
|
|
echo "Symlinking .config contents..."
|
|
for item in "$CONFIG_DIR"/*; do
|
|
[ -e "$item" ] || continue
|
|
baseitem="$(basename "$item")"
|
|
target_dir="$HOME/.config/$baseitem"
|
|
|
|
# Remove existing symlink or directory to avoid conflicts
|
|
[ -L "$target_dir" ] && rm "$target_dir"
|
|
[ -d "$target_dir" ] && [ ! -L "$target_dir" ] && rm -rf "$target_dir"
|
|
|
|
ln -sf "$item" "$target_dir"
|
|
echo "Linked .config/$baseitem"
|
|
done
|
|
|
|
# Device-specific symlinks for Hyprland and Waybar
|
|
if [ -n "$DOTFILES_DEVICE" ]; then
|
|
# Hyprland monitors
|
|
ln -sf "$CONFIG_DIR/hypr/includes/monitors-$DOTFILES_DEVICE.conf" "$CONFIG_DIR/hypr/includes/monitors.conf"
|
|
echo "Linked monitors-$DOTFILES_DEVICE.conf as monitors.conf"
|
|
# Hyprland input
|
|
ln -sf "$CONFIG_DIR/hypr/includes/input-$DOTFILES_DEVICE.conf" "$CONFIG_DIR/hypr/includes/input.conf"
|
|
echo "Linked input-$DOTFILES_DEVICE.conf as input.conf"
|
|
# Waybar config
|
|
ln -sf "$CONFIG_DIR/waybar/config-$DOTFILES_DEVICE" "$CONFIG_DIR/waybar/config"
|
|
echo "Linked config-$DOTFILES_DEVICE as waybar config"
|
|
fi
|
|
fi
|
|
|
|
echo "Dotfiles setup complete!"
|
|
|
|
# Symlink .local/bin scripts
|
|
LOCAL_BIN_REPO="$DOTFILES_DIR/.local/bin"
|
|
LOCAL_BIN_HOME="$HOME/.local/bin"
|
|
if [ -d "$LOCAL_BIN_REPO" ]; then
|
|
mkdir -p "$LOCAL_BIN_HOME"
|
|
echo "Symlinking .local/bin scripts..."
|
|
for script in "$LOCAL_BIN_REPO"/*; do
|
|
[ -e "$script" ] || continue
|
|
base_script="$(basename "$script")"
|
|
ln -sf "$script" "$LOCAL_BIN_HOME/$base_script"
|
|
echo "Linked .local/bin/$base_script"
|
|
done
|
|
fi
|
|
|