about summary refs log tree commit diff
path: root/dotfiles/.xinitrc
diff options
context:
space:
mode:
Diffstat (limited to 'dotfiles/.xinitrc')
-rw-r--r--dotfiles/.xinitrc16
1 files changed, 15 insertions, 1 deletions
diff --git a/dotfiles/.xinitrc b/dotfiles/.xinitrc
index 44cbad2..f8d567e 100644
--- a/dotfiles/.xinitrc
+++ b/dotfiles/.xinitrc
@@ -37,7 +37,21 @@ fi
 
 # NEEDED FOR NVIDIA DRIVERS
 if [ -x "$(command -v nvidia-smi)" ]; then
-  xrandr --setprovideroutputsource modesetting NVIDIA-0
+
+  # Preferred resolution + refresh rate
+  RES="3440x1440"
+  RATE="160.00"
+
+  # Find a connected display (DP-2, HDMI-0, etc.)
+  OUTPUT="$(xrandr | grep " connected" | cut -d' ' -f1)"
+
+  # Only switch if the mode exists
+  if xrandr | grep -qE "${RES}"; then
+    xrandr --output "$OUTPUT" --mode "$RES" --rate "$RATE"
+  else
+    # For PRIME / hybrid setups
+    xrandr --setprovideroutputsource modesetting NVIDIA-0
+   fi
 fi
 
 # NEEDED FOR CHROMEBOOK