Files
hyprarch/install.sh
2025-11-22 10:35:49 +01:00

430 lines
12 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# ╔═══════════════════════════════════════════════════════════════════╗
# ║ HYPRARCH - Install Script ║
# ║ https://git.cribdev.com/crib/hyprarch ║
# ╚═══════════════════════════════════════════════════════════════════╝
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Banner
echo -e "${CYAN}"
cat << "EOF"
╦ ╦╦ ╦╔═╗╦═╗╔═╗╦═╗╔═╗╦ ╦
╠═╣╚╦╝╠═╝╠╦╝╠═╣╠╦╝║ ╠═╣
╩ ╩ ╩ ╩ ╩╚═╩ ╩╩╚═╚═╝╩ ╩
Hyprland Rice for Arch Linux
EOF
echo -e "${NC}"
# Check if running as root
if [ "$EUID" -eq 0 ]; then
echo -e "${RED}Error: Please don't run this script as root${NC}"
exit 1
fi
# Check if running Arch Linux
if [ ! -f /etc/arch-release ]; then
echo -e "${RED}Error: This script is designed for Arch Linux${NC}"
exit 1
fi
# Function to print status
print_status() {
echo -e "${BLUE}[*]${NC} $1"
}
print_success() {
echo -e "${GREEN}[✓]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[!]${NC} $1"
}
print_error() {
echo -e "${RED}[✗]${NC} $1"
}
# Get script directory
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
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"
fi
# ── Step 3: Install Packages ─────────────────────────────────────────
print_status "Installing packages..."
# Core Hyprland packages
HYPRLAND_PKGS=(
hyprland
hyprpaper
hyprpicker
hypridle
hyprlock
xdg-desktop-portal-hyprland
)
# Wayland essentials
WAYLAND_PKGS=(
waybar
rofi-wayland
dunst
swww
grim
slurp
wl-clipboard
)
# System utilities
SYSTEM_PKGS=(
kitty
thunar
thunar-archive-plugin
file-roller
pavucontrol
brightnessctl
networkmanager
network-manager-applet
bluez
bluez-utils
blueman
pipewire
pipewire-alsa
pipewire-pulse
pipewire-jack
wireplumber
)
# Fonts
FONT_PKGS=(
ttf-jetbrains-mono-nerd
ttf-fira-code
noto-fonts
noto-fonts-cjk
noto-fonts-emoji
ttf-font-awesome
)
# CLI tools
CLI_PKGS=(
git
vim
neovim
htop
btop
wget
curl
unzip
zip
ripgrep
fd
fzf
bat
eza
jq
zsh
starship
)
# Applications
APP_PKGS=(
firefox
imv
zathura
zathura-pdf-mupdf
mpv
)
# Qt/GTK theming
THEME_PKGS=(
qt5ct
qt6ct
nwg-look
)
# 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 "${ALL_PKGS[@]}" || {
print_warning "Some packages may have failed, continuing..."
}
# AUR packages
AUR_PKGS=(
swaynotificationcenter
)
print_status "Installing AUR packages..."
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..."
# 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 "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"
"$HOME/.config/waybar"
"$HOME/.config/rofi"
"$HOME/.config/kitty"
"$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"
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"
else
print_success "No existing configs to backup"
fi
# ── Step 6: Install Configs ──────────────────────────────────────────
print_status "Installing configs..."
# Create directories
mkdir -p "$HOME/.config/hypr"
mkdir -p "$HOME/.config/waybar"
mkdir -p "$HOME/.config/rofi"
mkdir -p "$HOME/.config/kitty"
mkdir -p "$HOME/.config/dunst"
mkdir -p "$HOME/Pictures/wallpapers"
mkdir -p "$HOME/Pictures/screenshots"
# 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 | 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
print_success "Zsh already default shell"
else
print_status "Setting zsh as default shell..."
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"
[directory]
truncation_length = 3
truncate_to_repo = true
[character]
success_symbol = "[](bold green)"
error_symbol = "[](bold red)"
[git_branch]
format = "[$symbol$branch]($style) "
style = "bold purple"
EOF
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
# History
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt appendhistory
setopt sharehistory
setopt hist_ignore_dups
# Completion
autoload -Uz compinit
compinit
# Aliases
alias ls='eza'
alias ll='eza -la'
alias cat='bat'
alias vim='nvim'
alias update='sudo pacman -Syu'
alias cleanup='sudo pacman -Rns $(pacman -Qtdq)'
# Starship prompt
eval "$(starship init zsh)"
EOF
print_success "Zsh config installed"
# ── 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..."
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
if [ -f "$HOME/Pictures/wallpapers/default.jpg" ]; then
print_success "Wallpaper downloaded"
fi
fi
# ── Complete ─────────────────────────────────────────────────────────
echo ""
echo -e "${GREEN}╔═══════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ Installation Complete! ║${NC}"
echo -e "${GREEN}╚═══════════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${CYAN}Next steps:${NC}"
echo " 1. Log out and select Hyprland from your display manager"
echo " 2. Or start Hyprland from TTY: ${YELLOW}Hyprland${NC}"
echo ""
echo -e "${CYAN}Keybindings:${NC}"
echo " SUPER + Return → Terminal (Kitty)"
echo " SUPER + D → App Launcher (Rofi)"
echo " SUPER + Q → Close Window"
echo " SUPER + E → File Manager"
echo " SUPER + 1-9 → Switch Workspace"
echo ""
echo -e "${CYAN}Config locations:${NC}"
echo " Hyprland: ~/.config/hypr/hyprland.conf"
echo " Waybar: ~/.config/waybar/"
echo " Rofi: ~/.config/rofi/"
echo " Kitty: ~/.config/kitty/kitty.conf"
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}"