diff options
| author | Spacedio <spacedio@thernusen.net> | 2026-05-24 21:46:50 -0400 |
|---|---|---|
| committer | Spacedio <spacedio@thernusen.net> | 2026-05-24 21:46:50 -0400 |
| commit | c9631b31a16b18140b7e471193618f5618fd0521 (patch) | |
| tree | a74a31fba0c3ed81b373adaec85adfd04bb0f0d4 /system/usr | |
| parent | 7999b9ad79a5aba6b12be73a938c823fc5b329e8 (diff) | |
| download | dotfiles-c9631b31a16b18140b7e471193618f5618fd0521.tar.gz | |
Modification of the GPU toggle script. Added udev rules for future polybar integration.
Diffstat (limited to 'system/usr')
| -rwxr-xr-x | system/usr/gpu-toggle | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/system/usr/gpu-toggle b/system/usr/gpu-toggle index 4325829..35d6c47 100755 --- a/system/usr/gpu-toggle +++ b/system/usr/gpu-toggle @@ -11,12 +11,15 @@ DEVICE_ID="57:00.0" PCI_PATH="/sys/bus/pci/devices/0000:$DEVICE_ID" REQUIRED_MODULES=("nvidia_drm" "nvidia_modeset" "nvidia_uvm" "nvidia") -if [[ $EUID -ne 0 ]]; then - echo "[ERROR] Elevated privileges required. Please execute with sudo." - exit 1 -fi +check_sudo() { + if [[ $EUID -ne 0 ]]; then + echo "[ERROR] Elevated privileges required. Please execute with sudo." + exit 1 + fi +} check_status() { + local is_active=0 echo "--- System Graphics Status ---" if [ -d "$PCI_PATH" ]; then echo "Hardware State: [ ONLINE ] at $DEVICE_ID" @@ -25,14 +28,18 @@ check_status() { else echo "Driver State: [ UNLOADED ]" fi + is_active=0 else echo "Hardware State: [ OFFLINE ] (Device removed from PCI bus)" echo "Driver State: [ UNLOADED ]" + is_active=1 fi echo "------------------------------" + return $is_active } disable_gpu() { + check_sudo echo "[INFO] Initializing dGPU shutdown sequence..." # 1. Unload Kernel Modules @@ -57,6 +64,7 @@ disable_gpu() { } enable_gpu() { + check_sudo echo "[INFO] Initializing dGPU activation sequence..." # 1. Trigger PCI Rescan @@ -82,6 +90,6 @@ enable_gpu() { case "$1" in on) enable_gpu ;; off) disable_gpu ;; - status) check_status ;; + status) check_status; exit $? ;; *) echo "Usage: gpu-toggle {on|off|status}" ;; esac |
