From c5438baf5d0f7dbdbf7c172a218a5b1bbdea6f84 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Wed, 29 Mar 2017 03:01:07 +0200
Subject: [PATCH] Improve on previous commit.

---
 .../___etc___X11___xorg.conf.forced_nvidia    | 34 +++++++++++++++++++
 .../user/thinkpad/W530/startx_force_nvidia.sh |  2 +-
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 ansible/files/system/___etc___X11___xorg.conf.forced_nvidia

diff --git a/ansible/files/system/___etc___X11___xorg.conf.forced_nvidia b/ansible/files/system/___etc___X11___xorg.conf.forced_nvidia
new file mode 100644
index 0000000..605a10d
--- /dev/null
+++ b/ansible/files/system/___etc___X11___xorg.conf.forced_nvidia
@@ -0,0 +1,34 @@
+# This is the Optimus-specific configuration recommended by the "NVIDIA
+# Accelerated Linux Graphics Drivre README and Installation Guide", Chapter 32
+# "Offloading Graphics Display with RandR 1.4" 
+# (<http://us.download.nvidia.com/XFree86/Linux-x86/346.35/README/randr14.html>)
+# with the "AllowEmptyInitialConfigratuion" added as described by
+# <http://us.download.nvidia.com/XFree86/Linux-x86/346.35/README/randr14.html>.
+
+Section "ServerLayout"
+    Identifier "layout"
+    Screen 0 "nvidia"
+    Inactive "intel"
+EndSection
+
+Section "Device"
+    Identifier "nvidia"
+    Driver "nvidia"
+    BusID "PCI:01:00:0"
+    Option "AllowEmptyInitialConfiguration"
+EndSection
+
+Section "Screen"
+    Identifier "nvidia"
+    Device "nvidia"
+EndSection
+
+Section "Device"
+    Identifier "intel"
+    Driver "modesetting"
+EndSection
+
+Section "Screen"
+    Identifier "intel"
+    Device "intel"
+EndSection
diff --git a/dotfiles/user/thinkpad/W530/startx_force_nvidia.sh b/dotfiles/user/thinkpad/W530/startx_force_nvidia.sh
index babdbff..3c3ca59 100755
--- a/dotfiles/user/thinkpad/W530/startx_force_nvidia.sh
+++ b/dotfiles/user/thinkpad/W530/startx_force_nvidia.sh
@@ -6,7 +6,7 @@ sudo modprobe nvidia-drm
 sudo update-alternatives --set glx /usr/lib/nvidia
 
 # Use special xorg.conf and pass NVIDIA_DIRECT directive to .xinitrc.
-NVIDIA_DIRECT=1 startx -- -config xorg.conf.alt
+NVIDIA_DIRECT=1 startx -- -config xorg.conf.forced_nvidia
 
 # Recreate bumblebee setup.
 sudo service bumblebeed start
-- 
2.30.2