From f3e2ba7ca972bea7f45fb84bafa8c69054653e54 Mon Sep 17 00:00:00 2001 From: Derek Visch Date: Fri, 9 Jan 2026 21:31:39 -0500 Subject: [PATCH] Ensure Sleep with NVIDIA machines doesn't cause a black screen --- install/config/hardware/nvidia.sh | 3 ++- migrations/1768012038.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 migrations/1768012038.sh diff --git a/install/config/hardware/nvidia.sh b/install/config/hardware/nvidia.sh index 125addf6ac..88a7a1e4da 100644 --- a/install/config/hardware/nvidia.sh +++ b/install/config/hardware/nvidia.sh @@ -19,9 +19,10 @@ if [ -n "$NVIDIA" ]; then omarchy-pkg-add "$KERNEL_HEADERS" "${PACKAGES[@]}" - # Configure modprobe for early KMS + # Configure modprobe for early KMS and suspend/resume support sudo tee /etc/modprobe.d/nvidia.conf </dev/null options nvidia_drm modeset=1 +options nvidia NVreg_PreserveVideoMemoryAllocations=1 EOF # Configure mkinitcpio for early loading diff --git a/migrations/1768012038.sh b/migrations/1768012038.sh new file mode 100644 index 0000000000..030b54d390 --- /dev/null +++ b/migrations/1768012038.sh @@ -0,0 +1,30 @@ +echo "Add NVIDIA suspend/resume video memory preservation" + +# Only apply to systems with NVIDIA GPU +NVIDIA="$(lspci | grep -i 'nvidia')" +if [ -z "$NVIDIA" ]; then + exit 0 +fi + +NVIDIA_CONF="/etc/modprobe.d/nvidia.conf" + +# Check if the config already has the preserve setting +if [ -f "$NVIDIA_CONF" ] && grep -q "NVreg_PreserveVideoMemoryAllocations=1" "$NVIDIA_CONF"; then + echo "NVIDIA video memory preservation already configured" + exit 0 +fi + +# Add or update the nvidia.conf file +sudo tee "$NVIDIA_CONF" </dev/null +options nvidia_drm modeset=1 +options nvidia NVreg_PreserveVideoMemoryAllocations=1 +EOF + +echo "Regenerating initramfs..." +if omarchy-cmd-present limine-update; then + sudo limine-update +elif command -v mkinitcpio &>/dev/null; then + sudo mkinitcpio -P +fi + +omarchy-state set reboot-required