Fixed install script
This commit is contained in:
158
install.sh
158
install.sh
@@ -60,18 +60,32 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# ── Step 1: Update System ────────────────────────────────────────────
|
||||
print_status "Updating system..."
|
||||
sudo pacman -Syu --noconfirm
|
||||
print_success "System updated"
|
||||
|
||||
# ── 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)..."
|
||||
|
||||
# Install dependencies
|
||||
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
|
||||
cd /tmp/yay && makepkg -si --noconfirm
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
# Clean up
|
||||
rm -rf /tmp/yay
|
||||
|
||||
print_success "yay installed"
|
||||
else
|
||||
print_success "yay already installed"
|
||||
fi
|
||||
|
||||
# ── Step 3: Install Packages ─────────────────────────────────────────
|
||||
@@ -165,9 +179,22 @@ THEME_PKGS=(
|
||||
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..."
|
||||
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_PKGS=(
|
||||
@@ -175,21 +202,43 @@ AUR_PKGS=(
|
||||
)
|
||||
|
||||
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"
|
||||
|
||||
# ── Step 4: Enable 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 ──────────────────────────────────
|
||||
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)"
|
||||
NEEDS_BACKUP=false
|
||||
|
||||
configs_to_backup=(
|
||||
"$HOME/.config/hypr"
|
||||
@@ -199,15 +248,26 @@ configs_to_backup=(
|
||||
"$HOME/.config/dunst"
|
||||
)
|
||||
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
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"
|
||||
for config in "${configs_to_backup[@]}"; do
|
||||
if [ -d "$config" ] || [ -f "$config" ]; then
|
||||
cp -r "$config" "$BACKUP_DIR/" 2>/dev/null || true
|
||||
print_warning "Backed up $(basename $config)"
|
||||
fi
|
||||
done
|
||||
|
||||
print_success "Backup created at $BACKUP_DIR"
|
||||
done
|
||||
print_success "Backup created at $BACKUP_DIR"
|
||||
else
|
||||
print_success "No existing configs to backup"
|
||||
fi
|
||||
|
||||
# ── Step 6: Install Configs ──────────────────────────────────────────
|
||||
print_status "Installing configs..."
|
||||
@@ -221,30 +281,52 @@ mkdir -p "$HOME/.config/dunst"
|
||||
mkdir -p "$HOME/Pictures/wallpapers"
|
||||
mkdir -p "$HOME/Pictures/screenshots"
|
||||
|
||||
# Copy configs
|
||||
cp -r "$SCRIPT_DIR/.config/hypr/"* "$HOME/.config/hypr/"
|
||||
cp -r "$SCRIPT_DIR/.config/waybar/"* "$HOME/.config/waybar/"
|
||||
cp -r "$SCRIPT_DIR/.config/rofi/"* "$HOME/.config/rofi/"
|
||||
cp -r "$SCRIPT_DIR/.config/kitty/"* "$HOME/.config/kitty/"
|
||||
cp -r "$SCRIPT_DIR/.config/dunst/"* "$HOME/.config/dunst/"
|
||||
# Copy configs (overwrite existing)
|
||||
if [ -d "$SCRIPT_DIR/.config/hypr" ]; then
|
||||
cp -rf "$SCRIPT_DIR/.config/hypr/"* "$HOME/.config/hypr/"
|
||||
fi
|
||||
|
||||
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
|
||||
if [ -d "$SCRIPT_DIR/wallpapers" ] && [ "$(ls -A $SCRIPT_DIR/wallpapers 2>/dev/null)" ]; then
|
||||
cp -r "$SCRIPT_DIR/wallpapers/"* "$HOME/Pictures/wallpapers/"
|
||||
if [ -d "$SCRIPT_DIR/wallpapers" ] && [ "$(ls -A $SCRIPT_DIR/wallpapers 2>/dev/null | grep -v README)" ]; then
|
||||
cp -rf "$SCRIPT_DIR/wallpapers/"* "$HOME/Pictures/wallpapers/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
print_success "Configs installed"
|
||||
|
||||
# ── 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..."
|
||||
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)"
|
||||
fi
|
||||
|
||||
# ── Step 8: Install Starship Config ──────────────────────────────────
|
||||
print_status "Installing starship 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'
|
||||
add_newline = false
|
||||
format = "$directory$git_branch$git_status$character"
|
||||
@@ -266,6 +348,12 @@ print_success "Starship config installed"
|
||||
|
||||
# ── Step 9: Setup 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'
|
||||
# HYPRARCH - Zsh Config
|
||||
|
||||
@@ -296,14 +384,20 @@ EOF
|
||||
print_success "Zsh config installed"
|
||||
|
||||
# ── Step 10: Download Default Wallpaper ──────────────────────────────
|
||||
print_status "Downloading default wallpaper..."
|
||||
if command -v wget &> /dev/null; then
|
||||
if [ -f "$HOME/Pictures/wallpapers/default.jpg" ]; then
|
||||
print_success "Default wallpaper already exists"
|
||||
else
|
||||
print_status "Downloading default wallpaper..."
|
||||
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://images.unsplash.com/photo-1557682250-33bd709cbe85?w=1920" -O "$HOME/Pictures/wallpapers/default.jpg" 2>/dev/null || \
|
||||
print_warning "Could not download wallpaper, please add one manually"
|
||||
fi
|
||||
fi
|
||||
|
||||
print_success "Wallpaper downloaded"
|
||||
if [ -f "$HOME/Pictures/wallpapers/default.jpg" ]; then
|
||||
print_success "Wallpaper downloaded"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── Complete ─────────────────────────────────────────────────────────
|
||||
echo ""
|
||||
@@ -328,6 +422,8 @@ echo " Waybar: ~/.config/waybar/"
|
||||
echo " Rofi: ~/.config/rofi/"
|
||||
echo " Kitty: ~/.config/kitty/kitty.conf"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Backup of old configs: $BACKUP_DIR${NC}"
|
||||
echo ""
|
||||
if [ "$NEEDS_BACKUP" = true ]; then
|
||||
echo -e "${YELLOW}Backup of old configs: $BACKUP_DIR${NC}"
|
||||
echo ""
|
||||
fi
|
||||
echo -e "${GREEN}Enjoy your new rice! 🎨${NC}"
|
||||
|
||||
Reference in New Issue
Block a user