From 76655b46464d11a3413801769100fabe57f8c1ac Mon Sep 17 00:00:00 2001
From: askiiart <dev@askiiart.net>
Date: Thu, 16 Jan 2025 17:14:06 -0600
Subject: [PATCH] add nvidia stuff for hp probook 440 g7

---
 device-specific.sh | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/device-specific.sh b/device-specific.sh
index 94523d1..9c9a412 100755
--- a/device-specific.sh
+++ b/device-specific.sh
@@ -1,4 +1,7 @@
 #!/usr/bin/env bash
+
+command_exists() { type "$1" &>/dev/null; }
+
 if grep -q "Shyvana" /sys/devices/virtual/dmi/id/product_name; then
     cd /tmp/
     git clone https://github.com/WeirdTreeThing/chromebook-linux-audio --depth 1
@@ -6,4 +9,28 @@ if grep -q "Shyvana" /sys/devices/virtual/dmi/id/product_name; then
     ./setup-audio
     cd -
     rm -rf /tmp/chromebook-linux-audio/
-fi
\ No newline at end of file
+elif grep -q "HP ProBook 440 G7" /sys/devices/virtual/dmi/id/product_name; then
+    if command_exists "dnf"; then
+        sudo dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda vulkan xorg-x11-drv-nvidia-cuda-libs
+        sudo dnf mark user akmod-nvidia
+
+        # build nvidia module for all kernels
+        for item in $(rpm -qa kernel); do
+            item=${item#???????}
+            sudo dnf install kernel-$item kernel-devel-$item -y
+            sudo akmods --kernels $item --rebuild
+        done
+
+        # load modules early, otherwise the display manager loads first
+        # update: it doesn't detect them sooooo just removing the display manager instead
+        #echo 'force_drivers+=" nvidia nvidia_modeset nvidia_uvm nvidia_drm "' | sudo tee /etc/dracut.conf.d/nvidia.conf
+        sudo dracut --regenerate-all -f
+
+        sudo dnf remove sddm
+
+        # start sway with `--unsupported-gpu`
+        sudo sed -i 's/Exec=start-sway$/Exec=start-sway --unsupported-gpu/g' /usr/share/wayland-sessions/sway.desktop
+    else
+        echo "missing nvidia drivers"
+    fi
+fi