diff --git a/amd/amd-drivers.sh b/amd/amd-drivers.sh index 320b949..b198b21 100755 --- a/amd/amd-drivers.sh +++ b/amd/amd-drivers.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail # Don't allow users to run this script as root if ((EUID == 0)); then @@ -15,3 +16,19 @@ printf "\n" # This also covers AMD integrated/APU graphics, since they use the same amdgpu/Mesa driver stack as discrete Radeon cards echo "Installing AMD graphics drivers" sudo pacman -Syu --needed mesa lib32-mesa vulkan-radeon lib32-vulkan-radeon vulkan-icd-loader lib32-vulkan-icd-loader libva-mesa-driver lib32-libva-mesa-driver + +# CachyOS recommends increasing AMD's shader cache size to 12GB for gaming. +echo "Configuring AMD shader cache" +mkdir -p "$HOME/.config/environment.d" +gaming_config="$HOME/.config/environment.d/gaming.conf" +touch "$gaming_config" + +if grep -q '^MESA_SHADER_CACHE_MAX_SIZE=' "$gaming_config"; then + sed -i 's/^MESA_SHADER_CACHE_MAX_SIZE=.*/MESA_SHADER_CACHE_MAX_SIZE=12G/' "$gaming_config" +else + cat << 'EOF' >> "$gaming_config" + +# Increase AMD's shader cache size to 12GB +MESA_SHADER_CACHE_MAX_SIZE=12G +EOF +fi diff --git a/amd/hardware-acceleration.sh b/amd/hardware-acceleration.sh index 17c5b81..3c9a50e 100644 --- a/amd/hardware-acceleration.sh +++ b/amd/hardware-acceleration.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail # Don't allow users to run this script as root if ((EUID == 0)); then diff --git a/desktop-environment/gnome.sh b/desktop-environment/gnome.sh index 1e9b951..5ebb391 100644 --- a/desktop-environment/gnome.sh +++ b/desktop-environment/gnome.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail # Don't allow users to run this script as root if ((EUID == 0)); then @@ -19,9 +20,10 @@ if [[ -e /etc/systemd/system/display-manager.service ]]; then fi fi -# Enables the GDM display manager so GNOME starts automatically on boot +# Enables the GDM display manager so GNOME starts automatically on boot. +# --force replaces an existing display-manager.service symlink when switching DMs. echo "Enabling GDM display manager" -sudo systemctl enable gdm.service +sudo systemctl enable --force gdm.service # Enables NetworkManager so networking works out of the box in GNOME echo "Enabling NetworkManager" diff --git a/desktop-environment/kde-plasma.sh b/desktop-environment/kde-plasma.sh index b0aed8b..4ff1d85 100644 --- a/desktop-environment/kde-plasma.sh +++ b/desktop-environment/kde-plasma.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail # Don't allow users to run this script as root if ((EUID == 0)); then @@ -18,9 +19,10 @@ if [[ -e /etc/systemd/system/display-manager.service ]]; then fi fi -# Enables the SDDM display manager so KDE Plasma starts automatically on boot +# Enables the SDDM display manager so KDE Plasma starts automatically on boot. +# --force replaces an existing display-manager.service symlink when switching DMs. echo "Enabling SDDM display manager" -sudo systemctl enable sddm.service +sudo systemctl enable --force sddm.service # Enables NetworkManager so networking works out of the box in Plasma echo "Enabling NetworkManager" diff --git a/intel/hardware-acceleration.sh b/intel/hardware-acceleration.sh index 4d3f53e..518dab8 100644 --- a/intel/hardware-acceleration.sh +++ b/intel/hardware-acceleration.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail # Don't allow users to run this script as root if ((EUID == 0)); then diff --git a/intel/intel-drivers.sh b/intel/intel-drivers.sh index 330531d..2606ea2 100755 --- a/intel/intel-drivers.sh +++ b/intel/intel-drivers.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail # Don't allow users to run this script as root if ((EUID == 0)); then diff --git a/misc/disable-touchpad-mouse.sh b/misc/disable-touchpad-mouse.sh index a613a2e..e3d2698 100755 --- a/misc/disable-touchpad-mouse.sh +++ b/misc/disable-touchpad-mouse.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail # Don't allow users to run this script as root if ((EUID == 0)); then diff --git a/nvidia/hardware-acceleration.sh b/nvidia/hardware-acceleration.sh index eb252a5..c4e1d4c 100644 --- a/nvidia/hardware-acceleration.sh +++ b/nvidia/hardware-acceleration.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail # Don't allow users to run this script as root if ((EUID == 0)); then @@ -6,19 +7,19 @@ if ((EUID == 0)); then exit 1 fi -# Install packages for Nvidia hardware acceleration -echo "Installing Nvidia VA-API driver" +# Install packages for NVIDIA hardware acceleration +echo "Installing NVIDIA VA-API driver" sudo pacman -Syu --needed libva-nvidia-driver -# Sets environment variables for Nvidia hardware acceleration for VA-API, VDPAU, and CUDA -# Essentially improves video playback and hardware acceleration for Nvidia GPUs -if grep -q "Nvidia hardware acceleration environment variables" /etc/environment 2> /dev/null; then - echo "Nvidia hardware acceleration environment variables are already set, skipping." +# Sets environment variables for NVIDIA hardware acceleration for VA-API, VDPAU, and CUDA +# Essentially improves video playback and hardware acceleration for NVIDIA GPUs +if grep -q "NVIDIA hardware acceleration environment variables" /etc/environment 2> /dev/null; then + echo "NVIDIA hardware acceleration environment variables are already set, skipping." else - echo "Setting environment variables for Nvidia hardware acceleration" + echo "Setting environment variables for NVIDIA hardware acceleration" cat << 'EOF' | sudo tee -a /etc/environment > /dev/null -# Nvidia hardware acceleration environment variables +# NVIDIA hardware acceleration environment variables MOZ_DISABLE_RDD_SANDBOX=1 LIBVA_DRIVER_NAME=nvidia VDPAU_DRIVER=nvidia diff --git a/nvidia/nvidia-drivers.sh b/nvidia/nvidia-drivers.sh index 365b61c..c2816a2 100755 --- a/nvidia/nvidia-drivers.sh +++ b/nvidia/nvidia-drivers.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail # Don't allow users to run this script as root if ((EUID == 0)); then @@ -11,35 +12,43 @@ echo "If it's not enabled, please close the script and do that before running th read -n 1 -s -r -p "Press any key to continue..." printf "\n" -# Installs Nvidia, Vulkan, and OpenCL packages +# Installs NVIDIA, Vulkan, and OpenCL packages linux_kernel=$(uname -r) case "$linux_kernel" in *-arch*) - echo "Installing Nvidia drivers for Arch Linux kernel" + echo "Installing NVIDIA drivers for Arch Linux kernel" sudo pacman -Syu --needed nvidia-open nvidia-utils lib32-nvidia-utils nvidia-settings vulkan-icd-loader lib32-vulkan-icd-loader opencl-nvidia lib32-opencl-nvidia ;; *-lts*) - echo "Installing Nvidia drivers for Linux LTS kernel" + echo "Installing NVIDIA drivers for Linux LTS kernel" sudo pacman -Syu --needed nvidia-open-lts nvidia-utils lib32-nvidia-utils nvidia-settings vulkan-icd-loader lib32-vulkan-icd-loader opencl-nvidia lib32-opencl-nvidia ;; *-hardened*|*-zen*|*-cachyos*) - echo "Installing Nvidia drivers for Other Linux kernel: $linux_kernel" + echo "Installing NVIDIA drivers for other Linux kernel: $linux_kernel" sudo pacman -Syu --needed nvidia-open-dkms nvidia-utils lib32-nvidia-utils nvidia-settings vulkan-icd-loader lib32-vulkan-icd-loader opencl-nvidia lib32-opencl-nvidia ;; *) - echo "Installing Nvidia drivers for unknown kernel: $linux_kernel" + echo "Installing NVIDIA drivers for unknown kernel: $linux_kernel" sudo pacman -Syu --needed nvidia-open-dkms nvidia-utils lib32-nvidia-utils nvidia-settings vulkan-icd-loader lib32-vulkan-icd-loader opencl-nvidia lib32-opencl-nvidia ;; esac -# Creates a conf file to enable suspend and resizable bar, and also disables Nvidia link. -echo "Creating Nvidia modprobe file" +# Creates a conf file to enable suspend and resizable bar, and also disables NVIDIA link. +echo "Creating NVIDIA modprobe file" echo 'options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_EnableResizableBar=1 NVreg_NvLinkDisable=1 NVreg_UseKernelSuspendNotifiers=1' | sudo tee /etc/modprobe.d/nvidia-kernel-parameters.conf > /dev/null -# Increases maximum shader cache size to reduce stutters -echo "Creating Nvidia shader cache configuration file" -mkdir -p ~/.config/environment.d -cat << 'EOF' > ~/.config/environment.d/nvidia-shader-cache.conf -# Increase Nvidia's shader cache size to 12GB +# CachyOS recommends increasing NVIDIA's shader cache size to 12GB for gaming. +echo "Configuring NVIDIA shader cache" +mkdir -p "$HOME/.config/environment.d" +gaming_config="$HOME/.config/environment.d/gaming.conf" +touch "$gaming_config" + +if grep -q '^__GL_SHADER_DISK_CACHE_SIZE=' "$gaming_config"; then + sed -i 's/^__GL_SHADER_DISK_CACHE_SIZE=.*/__GL_SHADER_DISK_CACHE_SIZE=12000000000/' "$gaming_config" +else + cat << 'EOF' >> "$gaming_config" + +# Increase NVIDIA's shader cache size to 12GB __GL_SHADER_DISK_CACHE_SIZE=12000000000 EOF +fi