Last active
October 4, 2026 20:58
-
-
Save Speyll/ecad8917d5af6a15e929634ac6523aca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Optimized CachyOS/Arch Post-Installation Script for AMD/Wayland (Niri) | |
| # Author: Speyll | |
| set -e # Exit on error | |
| # Ensure script is not invoked directly as root | |
| TARGET_USER="${SUDO_USER:-$USER}" | |
| if [ "$TARGET_USER" = "root" ]; then | |
| echo "Error: Do not run this script directly as root or via 'sudo ./script.sh'." | |
| echo "Run it as your normal user: ./$(basename "$0")" | |
| exit 1 | |
| fi | |
| echo "Target user identified as: $TARGET_USER" | |
| # 1. Network & Pacman Parallel Download Optimization | |
| echo "Optimizing pacman configurations..." | |
| sudo sed -i 's/^#ParallelDownloads = .*/ParallelDownloads = 10/' /etc/pacman.conf | |
| sudo pacman -Syu --noconfirm | |
| # 2. Hardened Multi-GPU Driver Installation | |
| install_gpu_driver() { | |
| echo "Checking hardware and deploying graphics stack..." | |
| LSPCI_OUT=$(lspci | grep -E 'VGA|3D') | |
| # AMD GPU (Mesa + Vulkan + OpenCL) | |
| if echo "$LSPCI_OUT" | grep -iq "AMD"; then | |
| echo "AMD GPU detected. Installing Mesa & Vulkan drivers..." | |
| sudo pacman -S --noconfirm mesa vulkan-radeon libva-mesa-driver lib32-mesa lib32-vulkan-radeon opencl-mesa lib32-opencl-mesa amd-ucode | |
| fi | |
| # Intel GPU | |
| if echo "$LSPCI_OUT" | grep -iq "Intel"; then | |
| echo "Intel GPU detected. Installing Intel driver stack..." | |
| sudo pacman -S --noconfirm mesa vulkan-intel intel-media-driver libva-intel-driver libva-mesa-driver | |
| fi | |
| # NVIDIA GPU | |
| if echo "$LSPCI_OUT" | grep -iq "NVIDIA"; then | |
| echo "NVIDIA GPU detected. Installing NVIDIA driver stack..." | |
| sudo pacman -S --noconfirm nvidia-dkms nvidia-utils lib32-nvidia-utils nvidia-settings egl-wayland | |
| fi | |
| } | |
| # 3. System Core & Performance Optimizations Bulk List | |
| install_core_packages() { | |
| packages=( | |
| # Development, Shell & Microcode Core | |
| git tmux base-devel dash curl dbus bash-completion libnotify fzf | |
| # Performance Backends & Realtime | |
| rtkit profile-sync-daemon cpupower | |
| # Wayland Core & Display Server Bridge | |
| wayland xorg-xwayland xwayland-satellite xdg-utils | |
| xdg-desktop-portal-gnome xdg-desktop-portal-gtk xdg-desktop-portal | |
| # PipeWire Audio Infrastructure | |
| pipewire pipewire-alsa pipewire-pulse gst-plugin-pipewire pipewire-roc wireplumber | |
| # Niri Environment & Command-Line Layout Tools | |
| niri neovim alacritty wlsunset brightnessctl wlr-randr wl-clipboard cliphist hyprlock hypridle mako fuzzel htop swaybg | |
| # Fonts | |
| noto-fonts-emoji noto-fonts-cjk noto-fonts ttf-nerd-fonts-symbols | |
| # Lower-Level System/Archive Utilities | |
| unzip p7zip unrar xz networkmanager wireguard-tools udisks2 openrgb fuse2 fwupd | |
| pcmanfm-qt ffmpegthumbnailer totem webp-pixbuf-loader tumbler gvfs-smb gvfs-afc gvfs-mtp | |
| # System Themes & Security Backends | |
| breeze-gtk breeze-icons qt5ct qt6ct bluez hyprpolkitagent seahorse gnome-keyring | |
| ) | |
| echo "Deploying system packages..." | |
| sudo pacman -S --noconfirm "${packages[@]}" | |
| } | |
| # 4. AUR Helpers & Packages (Safely executed under non-root TARGET_USER) | |
| install_paru() { | |
| if ! command -v paru &> /dev/null; then | |
| echo "Bootstrapping Paru AUR helper..." | |
| git clone git clone https://aur.archlinux.org/paru.git /tmp/paru | |
| pushd /tmp/paru-bin | |
| makepkg -si --noconfirm | |
| popd | |
| rm -rf /tmp/paru | |
| fi | |
| } | |
| install_paru_packages() { | |
| aur_packages=( | |
| mpvpaper flavours qt6ct-kde | |
| ) | |
| echo "Deploying AUR specific binaries..." | |
| paru -Syu --noconfirm "${aur_packages[@]}" | |
| } | |
| # --- Execution --- | |
| install_gpu_driver | |
| install_core_packages | |
| install_paru | |
| install_paru_packages | |
| # 5. Universal TTY1 Autologin Setup | |
| echo "Configuring TTY1 automatic login for $TARGET_USER..." | |
| sudo mkdir -p /etc/systemd/system/getty@tty1.service.d | |
| cat << EOF | sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf > /dev/null | |
| [Service] | |
| ExecStart= | |
| ExecStart=-/usr/bin/agetty --autologin $TARGET_USER --noclear %I \$TERM | |
| EOF | |
| # 6. System Daemon Initialization | |
| echo "Enabling core system services..." | |
| sudo systemctl enable bluetooth.service | |
| sudo systemctl enable rtkit-daemon.service | |
| sudo systemctl enable NetworkManager.service | |
| # Enable Profile Sync Daemon | |
| systemctl --user enable psd.service | |
| # Enable User Audio Stack | |
| systemctl --user enable pipewire.service wireplumber.service pipewire-pulse.service | |
| # 7. Portals Configuration for Niri (Prevents portal delays) | |
| mkdir -p "$HOME/.config/xdg-desktop-portal" | |
| cat << EOF > "$HOME/.config/xdg-desktop-portal/portals.conf" | |
| [preferred] | |
| default=gnome;gtk; | |
| EOF | |
| # 8. User Space Setup & Dotfiles Environment | |
| if [ ! -d "$HOME/dotfiles" ]; then | |
| git clone https://github.com/speyll/dotfiles "$HOME/dotfiles" | |
| cp -a "$HOME/dotfiles/." "$HOME/" | |
| rm -rf "$HOME/dotfiles" | |
| rm -rf "$HOME/.git" | |
| rm -rf "$HOME/README.md" | |
| rm -rf "$HOME/.bash_profile" | |
| fi | |
| # Apply permissions safely (guarded against non-existent dirs) | |
| for dir in "$HOME/.local/bin" "$HOME/.local/share/applications" "$HOME/.config/autostart"; do | |
| [ -d "$dir" ] && chmod -R a+rx "$dir" | |
| done | |
| # Font and cursor tracking scripts | |
| [ -f "$HOME/.local/share/fonts/git-fonts.sh" ] && dash "$HOME/.local/share/fonts/git-fonts.sh" | |
| [ -f "$HOME/.local/share/icons/git-cursors.sh" ] && dash "$HOME/.local/share/icons/git-cursors.sh" | |
| # 9. Passwordless System Hooks for Wheel Group (Systemd Native) | |
| echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/halt, /usr/bin/poweroff, /usr/bin/reboot, /usr/bin/shutdown, /usr/bin/systemctl" \ | |
| | sudo tee /etc/sudoers.d/wheel > /dev/null | |
| echo "Initialization success. Complete live mirror of your workstation configuration is deployable." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Minimal Arch Linux X11 Post-Installation Script | |
| # Author: Speyll | |
| set -e | |
| # Detect the target non-root user (even if script is invoked with sudo) | |
| TARGET_USER="${SUDO_USER:-$USER}" | |
| if [ "$TARGET_USER" = "root" ]; then | |
| echo "Error: Do not run this script directly as root. Run it as your normal user." | |
| exit 1 | |
| fi | |
| echo "Target user identified as: $TARGET_USER" | |
| # 1. Optimize Pacman Parallel Downloads | |
| echo "Optimizing pacman configurations..." | |
| sudo sed -i 's/^#ParallelDownloads = .*/ParallelDownloads = 10/' /etc/pacman.conf | |
| sudo pacman -Syu --noconfirm | |
| # 2. Intel Graphics & Xorg Core Stack | |
| echo "Deploying Intel graphics and X11 core..." | |
| sudo pacman -S --noconfirm \ | |
| xorg-server xorg-xinit xorg-xsetroot xdotool xorg-xrandr xorg-xset xorg-xprop \ | |
| xf86-input-libinput mesa vulkan-intel intel-media-driver libva-intel-driver libva-mesa-driver \ | |
| libx11 libxft libxinerama libxrandr fontconfig pkgconf base-devel git dash | |
| # 3. Lightweight X11 Utilities, Audio & Network Stack | |
| echo "Deploying system utilities and audio..." | |
| sudo pacman -S --noconfirm \ | |
| networkmanager bluez bluez-utils pipewire pipewire-alsa pipewire-pulse wireplumber \ | |
| picom dunst feh redshift xclip slock brightnessctl maim \ | |
| unzip p7zip unrar xz udisks2 pcmanfm-qt fzf dbus \ | |
| noto-fonts-emoji noto-fonts ttf-nerd-fonts-symbols rtkit profile-sync-daemon cpupower clipcat pamixer lxqt-policykit htop | |
| # 4. Touchpad Configuration (Tap-to-click & Natural Scroll) | |
| echo "Configuring Xorg libinput touchpad rules..." | |
| sudo mkdir -p /etc/X11/xorg.conf.d | |
| cat << 'EOF' | sudo tee /etc/X11/xorg.conf.d/30-touchpad.conf > /dev/null | |
| Section "InputClass" | |
| Identifier "touchpad" | |
| Driver "libinput" | |
| MatchIsTouchpad "on" | |
| Option "Tapping" "on" | |
| Option "NaturalScrolling" "true" | |
| Option "ClickMethod" "clickfinger" | |
| Option "DisableWhileTyping" "true" | |
| EndSection | |
| EOF | |
| # 5. Universal TTY1 Autologin Setup | |
| echo "Configuring TTY1 automatic login for $TARGET_USER..." | |
| sudo mkdir -p /etc/systemd/system/getty@tty1.service.d | |
| cat << EOF | sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf > /dev/null | |
| [Service] | |
| ExecStart= | |
| ExecStart=-/usr/bin/agetty --autologin $TARGET_USER --noclear %I \$TERM | |
| EOF | |
| # 6. Enable System Daemons via Systemd | |
| echo "Enabling core system services..." | |
| sudo systemctl enable NetworkManager.service | |
| sudo systemctl enable rtkit-daemon.service | |
| sudo systemctl enable bluetooth.service | |
| systemctl --user enable psd.service | |
| systemctl --user enable pipewire.service wireplumber.service pipewire-pulse.service | |
| # 7. Bootstrap Paru for AUR Tools (dwm, st, dmenu extensions if needed) | |
| if ! command -v paru &> /dev/null; then | |
| echo "Bootstrapping Paru AUR helper..." | |
| git clone git clone https://aur.archlinux.org/paru.git /tmp/paru | |
| pushd /tmp/paru-bin | |
| makepkg -si --noconfirm | |
| popd | |
| rm -rf /tmp/paru | |
| fi | |
| # 8. User Space Setup & Dotfiles Environment | |
| if [ ! -d "$HOME/misc-dotfiles" ]; then | |
| git clone https://github.com/speyll/misc-dotfiles "$HOME/misc-dotfiles" | |
| cp -a "$HOME/misc-dotfiles/x11/." "$HOME/" | |
| rm -rf "$HOME/misc-dotfiles" | |
| rm -rf "$HOME/.git" | |
| rm -rf "$HOME/README.md" | |
| rm -rf "$HOME/.bash_profile" | |
| fi | |
| # Suckless | |
| mkdir -p $HOME/Downloads/git/ | |
| git clone https://git.suckless.org/dwm/ "$HOME/Downloads/git/dwm" | |
| git clone https://git.suckless.org/dmenu/ "$HOME/Downloads/git/dmenu" | |
| git clone https://git.suckless.org/st/ "$HOME/Downloads/git/st" | |
| cp -f $HOME/Downloads/dwm/config.def.h $HOME/Downloads/git/dwm/ | |
| cp -f $HOME/Downloads/dmenu/config.def.h $HOME/Downloads/git/dmenu/ | |
| cp -f $HOME/Downloads/st/config.def.h $HOME/Downloads/git/st/ | |
| # Apply absolute dynamic permissions path layout | |
| chmod -R a+rx "$HOME/.local/bin" 2>/dev/null || true | |
| chmod -R a+rx "$HOME/.local/share/applications" 2>/dev/null || true | |
| chmod -R a+rx "$HOME/.config/autostart" 2>/dev/null || true | |
| # Font and cursor tracking scripts (Handled under dash environment safely) | |
| [ -f "$HOME/.local/share/fonts/git-fonts.sh" ] && dash "$HOME/.local/share/fonts/git-fonts.sh" | |
| [ -f "$HOME/.local/share/icons/git-cursors.sh" ] && dash "$HOME/.local/share/icons/git-cursors.sh" | |
| # Passwordless power hooks for wheel group | |
| echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/halt, /usr/bin/poweroff, /usr/bin/reboot, /usr/bin/shutdown" \ | |
| | sudo tee /etc/sudoers.d/wheel > /dev/null | |
| echo "Arch minimal X11 setup complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment