Fixed install script

This commit is contained in:
2025-11-22 10:35:49 +01:00
parent 427564ad8a
commit f51a7477af

View File

@@ -60,18 +60,32 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# ── Step 1: Update System ──────────────────────────────────────────── # ── Step 1: Update System ────────────────────────────────────────────
print_status "Updating system..." print_status "Updating system..."
sudo pacman -Syu --noconfirm sudo pacman -Syu --noconfirm
print_success "System updated"
# ── Step 2: Install yay (AUR helper) ───────────────────────────────── # ── Step 2: Install yay (AUR helper) ─────────────────────────────────
if ! command -v yay &> /dev/null; then if command -v yay &> /dev/null; then
print_success "yay already installed, skipping..."
else
print_status "Installing yay (AUR helper)..." print_status "Installing yay (AUR helper)..."
# Install dependencies
sudo pacman -S --needed --noconfirm git base-devel sudo pacman -S --needed --noconfirm git base-devel
# Clean up any previous failed attempts
if [ -d "/tmp/yay" ]; then
print_warning "Removing old /tmp/yay directory..."
rm -rf /tmp/yay
fi
# Clone and build
git clone https://aur.archlinux.org/yay.git /tmp/yay git clone https://aur.archlinux.org/yay.git /tmp/yay
cd /tmp/yay && makepkg -si --noconfirm cd /tmp/yay && makepkg -si --noconfirm
cd "$SCRIPT_DIR" cd "$SCRIPT_DIR"
# Clean up
rm -rf /tmp/yay rm -rf /tmp/yay
print_success "yay installed" print_success "yay installed"
else
print_success "yay already installed"
fi fi
# ── Step 3: Install Packages ───────────────────────────────────────── # ── Step 3: Install Packages ─────────────────────────────────────────
@@ -165,9 +179,22 @@ THEME_PKGS=(
nwg-look nwg-look
) )
# Install official packages # Combine all packages
ALL_PKGS=(
"${HYPRLAND_PKGS[@]}"
"${WAYLAND_PKGS[@]}"
"${SYSTEM_PKGS[@]}"
"${FONT_PKGS[@]}"
"${CLI_PKGS[@]}"
"${APP_PKGS[@]}"
"${THEME_PKGS[@]}"
)
# Install official packages (--needed skips already installed)
print_status "Installing official packages..." print_status "Installing official packages..."
sudo pacman -S --needed --noconfirm "${HYPRLAND_PKGS[@]}" "${WAYLAND_PKGS[@]}" "${SYSTEM_PKGS[@]}" "${FONT_PKGS[@]}" "${CLI_PKGS[@]}" "${APP_PKGS[@]}" "${THEME_PKGS[@]}" sudo pacman -S --needed --noconfirm "${ALL_PKGS[@]}" || {
print_warning "Some packages may have failed, continuing..."
}
# AUR packages # AUR packages
AUR_PKGS=( AUR_PKGS=(
@@ -175,21 +202,43 @@ AUR_PKGS=(
) )
print_status "Installing AUR packages..." print_status "Installing AUR packages..."
yay -S --needed --noconfirm "${AUR_PKGS[@]}" for pkg in "${AUR_PKGS[@]}"; do
if pacman -Qi "$pkg" &> /dev/null; then
print_success "$pkg already installed, skipping..."
else
print_status "Installing $pkg from AUR..."
yay -S --needed --noconfirm "$pkg" || print_warning "Failed to install $pkg"
fi
done
print_success "All packages installed" print_success "All packages installed"
# ── Step 4: Enable Services ────────────────────────────────────────── # ── Step 4: Enable Services ──────────────────────────────────────────
print_status "Enabling services..." print_status "Enabling services..."
sudo systemctl enable NetworkManager
sudo systemctl enable bluetooth
systemctl --user enable pipewire pipewire-pulse wireplumber
print_success "Services enabled" # System services
if systemctl is-enabled NetworkManager &> /dev/null; then
print_success "NetworkManager already enabled"
else
sudo systemctl enable NetworkManager
print_success "NetworkManager enabled"
fi
if systemctl is-enabled bluetooth &> /dev/null; then
print_success "Bluetooth already enabled"
else
sudo systemctl enable bluetooth || print_warning "Could not enable bluetooth"
print_success "Bluetooth enabled"
fi
# User services (PipeWire)
systemctl --user enable pipewire pipewire-pulse wireplumber 2>/dev/null || true
print_success "Services configured"
# ── Step 5: Backup Existing Configs ────────────────────────────────── # ── Step 5: Backup Existing Configs ──────────────────────────────────
print_status "Backing up existing configs..." print_status "Checking for existing configs to backup..."
BACKUP_DIR="$HOME/.config-backup-$(date +%Y%m%d_%H%M%S)" BACKUP_DIR="$HOME/.config-backup-$(date +%Y%m%d_%H%M%S)"
NEEDS_BACKUP=false
configs_to_backup=( configs_to_backup=(
"$HOME/.config/hypr" "$HOME/.config/hypr"
@@ -199,6 +248,15 @@ configs_to_backup=(
"$HOME/.config/dunst" "$HOME/.config/dunst"
) )
for config in "${configs_to_backup[@]}"; do
if [ -d "$config" ] || [ -f "$config" ]; then
NEEDS_BACKUP=true
break
fi
done
if [ "$NEEDS_BACKUP" = true ]; then
print_status "Backing up existing configs..."
mkdir -p "$BACKUP_DIR" mkdir -p "$BACKUP_DIR"
for config in "${configs_to_backup[@]}"; do for config in "${configs_to_backup[@]}"; do
if [ -d "$config" ] || [ -f "$config" ]; then if [ -d "$config" ] || [ -f "$config" ]; then
@@ -206,8 +264,10 @@ for config in "${configs_to_backup[@]}"; do
print_warning "Backed up $(basename $config)" print_warning "Backed up $(basename $config)"
fi fi
done done
print_success "Backup created at $BACKUP_DIR" print_success "Backup created at $BACKUP_DIR"
else
print_success "No existing configs to backup"
fi
# ── Step 6: Install Configs ────────────────────────────────────────── # ── Step 6: Install Configs ──────────────────────────────────────────
print_status "Installing configs..." print_status "Installing configs..."
@@ -221,30 +281,52 @@ mkdir -p "$HOME/.config/dunst"
mkdir -p "$HOME/Pictures/wallpapers" mkdir -p "$HOME/Pictures/wallpapers"
mkdir -p "$HOME/Pictures/screenshots" mkdir -p "$HOME/Pictures/screenshots"
# Copy configs # Copy configs (overwrite existing)
cp -r "$SCRIPT_DIR/.config/hypr/"* "$HOME/.config/hypr/" if [ -d "$SCRIPT_DIR/.config/hypr" ]; then
cp -r "$SCRIPT_DIR/.config/waybar/"* "$HOME/.config/waybar/" cp -rf "$SCRIPT_DIR/.config/hypr/"* "$HOME/.config/hypr/"
cp -r "$SCRIPT_DIR/.config/rofi/"* "$HOME/.config/rofi/" fi
cp -r "$SCRIPT_DIR/.config/kitty/"* "$HOME/.config/kitty/"
cp -r "$SCRIPT_DIR/.config/dunst/"* "$HOME/.config/dunst/" if [ -d "$SCRIPT_DIR/.config/waybar" ]; then
cp -rf "$SCRIPT_DIR/.config/waybar/"* "$HOME/.config/waybar/"
fi
if [ -d "$SCRIPT_DIR/.config/rofi" ]; then
cp -rf "$SCRIPT_DIR/.config/rofi/"* "$HOME/.config/rofi/"
fi
if [ -d "$SCRIPT_DIR/.config/kitty" ]; then
cp -rf "$SCRIPT_DIR/.config/kitty/"* "$HOME/.config/kitty/"
fi
if [ -d "$SCRIPT_DIR/.config/dunst" ]; then
cp -rf "$SCRIPT_DIR/.config/dunst/"* "$HOME/.config/dunst/"
fi
# Copy wallpapers if they exist # Copy wallpapers if they exist
if [ -d "$SCRIPT_DIR/wallpapers" ] && [ "$(ls -A $SCRIPT_DIR/wallpapers 2>/dev/null)" ]; then if [ -d "$SCRIPT_DIR/wallpapers" ] && [ "$(ls -A $SCRIPT_DIR/wallpapers 2>/dev/null | grep -v README)" ]; then
cp -r "$SCRIPT_DIR/wallpapers/"* "$HOME/Pictures/wallpapers/" cp -rf "$SCRIPT_DIR/wallpapers/"* "$HOME/Pictures/wallpapers/" 2>/dev/null || true
fi fi
print_success "Configs installed" print_success "Configs installed"
# ── Step 7: Set Zsh as Default Shell ───────────────────────────────── # ── Step 7: Set Zsh as Default Shell ─────────────────────────────────
if [ "$SHELL" != "$(which zsh)" ]; then if [ "$SHELL" = "$(which zsh)" ]; then
print_success "Zsh already default shell"
else
print_status "Setting zsh as default shell..." print_status "Setting zsh as default shell..."
chsh -s $(which zsh) chsh -s $(which zsh) || print_warning "Could not change shell, run manually: chsh -s $(which zsh)"
print_success "Zsh set as default shell (will take effect on next login)" print_success "Zsh set as default shell (will take effect on next login)"
fi fi
# ── Step 8: Install Starship Config ────────────────────────────────── # ── Step 8: Install Starship Config ──────────────────────────────────
print_status "Installing starship config..." print_status "Installing starship config..."
mkdir -p "$HOME/.config" mkdir -p "$HOME/.config"
if [ -f "$HOME/.config/starship.toml" ]; then
print_warning "Starship config exists, backing up..."
cp "$HOME/.config/starship.toml" "$HOME/.config/starship.toml.bak"
fi
cat > "$HOME/.config/starship.toml" << 'EOF' cat > "$HOME/.config/starship.toml" << 'EOF'
add_newline = false add_newline = false
format = "$directory$git_branch$git_status$character" format = "$directory$git_branch$git_status$character"
@@ -266,6 +348,12 @@ print_success "Starship config installed"
# ── Step 9: Setup Zsh Config ───────────────────────────────────────── # ── Step 9: Setup Zsh Config ─────────────────────────────────────────
print_status "Setting up zsh config..." print_status "Setting up zsh config..."
if [ -f "$HOME/.zshrc" ]; then
print_warning ".zshrc exists, backing up to .zshrc.bak"
cp "$HOME/.zshrc" "$HOME/.zshrc.bak"
fi
cat > "$HOME/.zshrc" << 'EOF' cat > "$HOME/.zshrc" << 'EOF'
# HYPRARCH - Zsh Config # HYPRARCH - Zsh Config
@@ -296,6 +384,9 @@ EOF
print_success "Zsh config installed" print_success "Zsh config installed"
# ── Step 10: Download Default Wallpaper ────────────────────────────── # ── Step 10: Download Default Wallpaper ──────────────────────────────
if [ -f "$HOME/Pictures/wallpapers/default.jpg" ]; then
print_success "Default wallpaper already exists"
else
print_status "Downloading default wallpaper..." print_status "Downloading default wallpaper..."
if command -v wget &> /dev/null; then if command -v wget &> /dev/null; then
wget -q "https://raw.githubusercontent.com/linuxdotexe/nordic-wallpapers/master/wallpapers/ign_astronaut.png" -O "$HOME/Pictures/wallpapers/default.jpg" 2>/dev/null || \ wget -q "https://raw.githubusercontent.com/linuxdotexe/nordic-wallpapers/master/wallpapers/ign_astronaut.png" -O "$HOME/Pictures/wallpapers/default.jpg" 2>/dev/null || \
@@ -303,7 +394,10 @@ if command -v wget &> /dev/null; then
print_warning "Could not download wallpaper, please add one manually" print_warning "Could not download wallpaper, please add one manually"
fi fi
if [ -f "$HOME/Pictures/wallpapers/default.jpg" ]; then
print_success "Wallpaper downloaded" print_success "Wallpaper downloaded"
fi
fi
# ── Complete ───────────────────────────────────────────────────────── # ── Complete ─────────────────────────────────────────────────────────
echo "" echo ""
@@ -328,6 +422,8 @@ echo " Waybar: ~/.config/waybar/"
echo " Rofi: ~/.config/rofi/" echo " Rofi: ~/.config/rofi/"
echo " Kitty: ~/.config/kitty/kitty.conf" echo " Kitty: ~/.config/kitty/kitty.conf"
echo "" echo ""
if [ "$NEEDS_BACKUP" = true ]; then
echo -e "${YELLOW}Backup of old configs: $BACKUP_DIR${NC}" echo -e "${YELLOW}Backup of old configs: $BACKUP_DIR${NC}"
echo "" echo ""
fi
echo -e "${GREEN}Enjoy your new rice! 🎨${NC}" echo -e "${GREEN}Enjoy your new rice! 🎨${NC}"