301 lines
9.8 KiB
Bash
301 lines
9.8 KiB
Bash
#!/bin/bash
|
|
|
|
# Arch Linux System Setup Module
|
|
# Handles system packages, drivers, and core system configuration
|
|
|
|
arch_install_system_base() {
|
|
log SECTION "Installing Arch system base packages"
|
|
local section_start=$(date +%s)
|
|
|
|
if confirm "Install essential system packages?"; then
|
|
local packages=(
|
|
base-devel linux-headers git bc cmake gawk wget gettext unzip curl
|
|
inetutils python python-pip python-pipx python-pynvim rustup timeshift
|
|
)
|
|
|
|
install_packages "${packages[@]}"
|
|
|
|
# Setup Rust
|
|
rustup update stable
|
|
rustup default stable
|
|
|
|
log SUCCESS "System base packages installed $(show_timer $section_start)"
|
|
fi
|
|
}
|
|
|
|
arch_install_drivers() {
|
|
log SECTION "Installing graphics drivers"
|
|
local section_start=$(date +%s)
|
|
|
|
if role_enabled "NVIDIA_GPU" || role_enabled "NVIDIA_1080_GPU"; then
|
|
if confirm "Install NVIDIA drivers?"; then
|
|
log INFO "Installing NVIDIA drivers..."
|
|
|
|
# Check if we already have nvidia drivers
|
|
local new_kernel="no"
|
|
if ! package_installed nvidia-open-dkms && ! package_installed nvidia-dkms; then
|
|
new_kernel="yes"
|
|
fi
|
|
|
|
local nvidia_packages=(nvidia-dkms nvidia-utils nvidia-settings opencl-nvidia)
|
|
|
|
# Add CUDA for high-end GPUs
|
|
if role_enabled "NVIDIA_1080_GPU"; then
|
|
nvidia_packages+=(cuda)
|
|
fi
|
|
|
|
# Add 32-bit libs for gaming
|
|
if role_enabled "GAME"; then
|
|
nvidia_packages+=(lib32-nvidia-utils)
|
|
fi
|
|
|
|
install_packages "${nvidia_packages[@]}"
|
|
|
|
if [ "$new_kernel" == "yes" ]; then
|
|
log WARNING "NVIDIA driver updated - kernel rebuild required"
|
|
log WARNING "Please reboot and run the script again after reboot"
|
|
exit 0
|
|
fi
|
|
|
|
log SUCCESS "NVIDIA drivers installed $(show_timer $section_start)"
|
|
fi
|
|
else
|
|
if confirm "Install Intel graphics drivers?"; then
|
|
log INFO "Installing Intel graphics drivers..."
|
|
install_packages mesa intel-media-driver
|
|
log SUCCESS "Intel drivers installed $(show_timer $section_start)"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
arch_setup_multilib() {
|
|
if role_enabled "GAME"; then
|
|
log SECTION "Enabling multilib repository"
|
|
if ! grep -q "^\[multilib\]" /etc/pacman.conf; then
|
|
if confirm "Enable multilib repository for gaming?"; then
|
|
log INFO "Adding multilib repository..."
|
|
sudo tee -a /etc/pacman.conf >/dev/null <<EOT
|
|
|
|
[multilib]
|
|
Include = /etc/pacman.d/mirrorlist
|
|
EOT
|
|
log SUCCESS "Multilib repository enabled"
|
|
# Refresh databases after adding multilib
|
|
update_package_databases
|
|
fi
|
|
else
|
|
log INFO "Multilib repository already enabled"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
arch_install_hyprland() {
|
|
if ! role_enabled "HYPERLAND"; then
|
|
return 0
|
|
fi
|
|
|
|
log SECTION "Installing Hyprland desktop environment"
|
|
local section_start=$(date +%s)
|
|
|
|
if confirm "Install Hyprland desktop environment?"; then
|
|
# Core Hyprland packages
|
|
local hypr_packages=(
|
|
wayvnc nm-connection-editor usbutils plymouth dracut dunst hyprpaper
|
|
hypridle hyprland hyprlock xdg-desktop-portal-hyprland polkit-gnome
|
|
xorg-xhost gnome-keyring qt6ct gnome-themes-extra qt5-wayland qt6-wayland
|
|
lxappearance qt5-tools adwaita-fonts gnome-disk-utility tk
|
|
)
|
|
|
|
install_packages "${hypr_packages[@]}"
|
|
|
|
# AUR packages for Hyprland
|
|
local hypr_aur_packages=(
|
|
adwaita-qt5-git adwaita-qt6-git hyprshot walker-bin
|
|
)
|
|
|
|
install_aur_packages "${hypr_aur_packages[@]}"
|
|
|
|
# Create configuration directories
|
|
mkdir -p ~/.config/hypr ~/.local/bin
|
|
|
|
# Link Hyprland configurations
|
|
local hostname="${SYSTEM_INFO[HOSTNAME]}"
|
|
if [ -f ~/linuxbox/config/hypr/hyprland_$hostname.conf ]; then
|
|
ln -sf ~/linuxbox/config/hypr/hyprland_$hostname.conf ~/.config/hypr/hyprland_extra.conf
|
|
else
|
|
touch ~/.config/hypr/hyprland_extra.conf
|
|
fi
|
|
|
|
if [ -f ~/linuxbox/config/hypr/hypridle_$hostname.conf ]; then
|
|
ln -sf ~/linuxbox/config/hypr/hypridle_$hostname.conf ~/.config/hypr/hypridle.conf
|
|
else
|
|
ln -sf ~/linuxbox/config/hypr/hypridle.conf ~/.config/hypr/hypridle.conf
|
|
fi
|
|
|
|
# Link main configurations
|
|
ln -sf ~/linuxbox/config/hypr/hyprland.conf ~/.config/hypr/hyprland.conf
|
|
ln -sf ~/linuxbox/wrappedhl ~/.local/bin/wrappedhl
|
|
ln -sf ~/linuxbox/config/hypr/hyprpaper.conf ~/.config/hypr/hyprpaper.conf
|
|
|
|
# Link theme configurations
|
|
ln -sf ~/linuxbox/config/gtk-3.0 ~/.config
|
|
ln -sf ~/linuxbox/config/qt5ct ~/.config
|
|
ln -sf ~/linuxbox/config/qt6ct ~/.config
|
|
ln -sf ~/linuxbox/config/dunst ~/.config
|
|
ln -sf ~/linuxbox/config/walker ~/.config
|
|
|
|
log SUCCESS "Hyprland desktop environment installed $(show_timer $section_start)"
|
|
fi
|
|
}
|
|
|
|
arch_install_waybar() {
|
|
if ! role_enabled "HYPERLAND"; then
|
|
return 0
|
|
fi
|
|
|
|
log SECTION "Installing Waybar"
|
|
local section_start=$(date +%s)
|
|
|
|
if confirm "Install Waybar status bar?"; then
|
|
install_packages waybar
|
|
|
|
mkdir -p ~/.config/waybar
|
|
ln -sf ~/linuxbox/config/waybar/config ~/.config/waybar/config
|
|
ln -sf ~/linuxbox/config/waybar/style.css ~/.config/waybar/style.css
|
|
|
|
log SUCCESS "Waybar installed $(show_timer $section_start)"
|
|
fi
|
|
}
|
|
|
|
arch_setup_autologin() {
|
|
if ! role_enabled "HYPERLAND"; then
|
|
return 0
|
|
fi
|
|
|
|
log SECTION "Setting up autologin"
|
|
local section_start=$(date +%s)
|
|
|
|
if confirm "Setup automatic login?"; then
|
|
install_aur_packages pam_autologin
|
|
|
|
sudo /bin/cp -rf ~/linuxbox/login /etc/pam.d/login
|
|
sudo /bin/cp -rf ~/linuxbox/getty@.service /usr/lib/systemd/system/getty@.service
|
|
sudo touch /etc/security/autologin.conf
|
|
|
|
log SUCCESS "Autologin configured $(show_timer $section_start)"
|
|
fi
|
|
}
|
|
|
|
arch_setup_storage() {
|
|
log SECTION "Setting up storage and mounting"
|
|
local section_start=$(date +%s)
|
|
|
|
if confirm "Setup udisks2 for automatic mounting?"; then
|
|
install_packages udisks2 udiskie
|
|
|
|
echo 'ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"' | \
|
|
sudo tee /lib/udev/rules.d/99-udisks2.rules
|
|
echo 'D /media 0755 root root 0 -' | sudo tee /etc/tmpfiles.d/media.conf
|
|
|
|
# Special configuration for STEAMBOX
|
|
if [ "${SYSTEM_INFO[HOSTNAME]}" == "STEAMBOX" ]; then
|
|
echo "$USER ALL=(ALL:ALL) NOPASSWD: /usr/sbin/udisksctl mount -b /dev/sda1" | \
|
|
sudo tee /etc/sudoers.d/udisksctl
|
|
fi
|
|
|
|
log SUCCESS "Storage setup completed $(show_timer $section_start)"
|
|
fi
|
|
}
|
|
|
|
arch_setup_audio() {
|
|
log SECTION "Setting up audio system"
|
|
local section_start=$(date +%s)
|
|
|
|
if confirm "Setup PipeWire audio system?"; then
|
|
local audio_packages=(pipewire pipewire-pulse pipewire-alsa pavucontrol helvum)
|
|
|
|
# Add JACK support for music production
|
|
if role_enabled "MUSIC"; then
|
|
audio_packages+=(pipewire-jack qpwgraph realtime-privileges gamemode)
|
|
fi
|
|
|
|
install_packages "${audio_packages[@]}"
|
|
|
|
# Setup PipeWire configuration
|
|
mkdir -p ~/.config/pipewire
|
|
if [ -f ~/linuxbox/config/pipewire/pipewire.conf ]; then
|
|
ln -sf ~/linuxbox/config/pipewire/pipewire.conf ~/.config/pipewire/pipewire.conf
|
|
fi
|
|
|
|
# Music production setup
|
|
if role_enabled "MUSIC"; then
|
|
# Add user to audio groups
|
|
sudo usermod -a -G realtime,audio,gamemode $USER
|
|
|
|
# Setup realtime privileges
|
|
sudo tee /etc/security/limits.d/99-pipewire.conf <<'EOF'
|
|
@audio soft rtprio 95
|
|
@audio soft memlock unlimited
|
|
@audio hard rtprio 95
|
|
@audio hard memlock unlimited
|
|
EOF
|
|
|
|
# Enable and configure PipeWire services
|
|
systemctl --user --now enable pipewire{,-pulse}.{socket,service} filter-chain.service || true
|
|
pw-metadata -n settings 0 clock.min-quantum 128 || true
|
|
fi
|
|
|
|
log SUCCESS "Audio system configured $(show_timer $section_start)"
|
|
fi
|
|
}
|
|
|
|
arch_install_caffeine() {
|
|
if ! role_enabled "HYPERLAND" && ! role_enabled "DESKTOP_BASE"; then
|
|
return 0
|
|
fi
|
|
|
|
log SECTION "Installing Caffeine"
|
|
local section_start=$(date +%s)
|
|
|
|
if confirm "Install Caffeine to prevent screen lock?"; then
|
|
install_aur_packages caffeine-ng
|
|
log SUCCESS "Caffeine installed $(show_timer $section_start)"
|
|
fi
|
|
}
|
|
|
|
arch_setup_bluetooth() {
|
|
if ! role_enabled "BT"; then
|
|
return 0
|
|
fi
|
|
|
|
log SECTION "Setting up Bluetooth"
|
|
local section_start=$(date +%s)
|
|
|
|
if confirm "Setup Bluetooth support?"; then
|
|
install_packages bluez bluez-utils blueman
|
|
|
|
sudo systemctl enable bluetooth.service
|
|
sudo systemctl start bluetooth.service
|
|
|
|
log SUCCESS "Bluetooth configured $(show_timer $section_start)"
|
|
fi
|
|
}
|
|
|
|
# Main function to run all system setup
|
|
arch_setup_system() {
|
|
arch_install_system_base
|
|
arch_setup_multilib
|
|
arch_install_drivers
|
|
arch_install_hyprland
|
|
arch_install_waybar
|
|
arch_setup_autologin
|
|
arch_setup_storage
|
|
arch_setup_audio
|
|
arch_install_caffeine
|
|
arch_setup_bluetooth
|
|
}
|
|
|
|
# Source guard
|
|
if [ -z "$ARCH_SYSTEM_LOADED" ]; then
|
|
ARCH_SYSTEM_LOADED=true
|
|
fi |