From 5f8038315d8398e846ee2249f9ea33de23c88360 Mon Sep 17 00:00:00 2001
From: andrey <andrey999@i.ua>
Date: Tue, 18 Aug 2020 22:33:45 +0300
Subject: [PATCH 1/2] =?UTF-8?q?=D0=9F=D0=BE=D1=82=D0=B4=D0=B5=D1=80=D0=B6?=
 =?UTF-8?q?=D0=BA=D0=B0=20=D0=B3=D0=B8=D0=B1=D1=80=D0=B8=D0=B4=D0=BD=D0=BE?=
 =?UTF-8?q?=D0=B9=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=B8=20=D0=BD?=
 =?UTF-8?q?=D0=B0=20=D1=81=D1=82=D0=B0=D1=80=D1=8B=D1=85=20=D0=B4=D1=80?=
 =?UTF-8?q?=D0=B0=D0=B9=D0=B2=D0=B5=D1=80=D0=B0=D1=85=20=D0=B2=D0=B8=D0=B4?=
 =?UTF-8?q?=D0=B5=D0=BE=D0=BA=D0=B0=D1=80=D1=82,=20=D0=B8=20=D1=82=D0=B0?=
 =?UTF-8?q?=D0=BA=D0=B6=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?=
 =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=B0=D1=80=D1=82=D0=B0=D1=85=20Intel?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 data_from_portwine/scripts/runlib | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/data_from_portwine/scripts/runlib b/data_from_portwine/scripts/runlib
index 5136b1fa..55aa2a20 100755
--- a/data_from_portwine/scripts/runlib
+++ b/data_from_portwine/scripts/runlib
@@ -132,15 +132,25 @@ else
     echo "Use OpenGL mod." 
 fi
 ########################################################################
+export gpu_card=""
+if [ -x "`which optimus-manager 2>/dev/null`" ]; then
+    export gpu_card=`optimus-manager --status | grep Current | cut -f 2 -d':' | sed -e 's/^[[:space:]]*//'`
+fi
 export optirun_on=
 export PW_NVIDIA="$(lspci | grep NVIDIA)" 
-if [ ! -z "${PW_NVIDIA}" ]; then
+if [[ "$gpu_card" == "nvidia" ]] || [[ ! -z "${PW_NVIDIA}" ]] && [[ "$gpu_card" != "intel" ]]; then
     if [ -x "`which primusrun 2>/dev/null`" ]; then
-        export optirun_on="primusrun"
-        export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json 
+        if [[ "$gpu_card" == "" ]]; then
+          export optirun_on="primusrun"
+        else
+            export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json
+        fi
     elif [ -x "`which optirun 2>/dev/null`" ]; then
-        export optirun_on="optirun -b primus"
-        export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json 
+        if [[ "$gpu_card" == "" ]]; then
+            export optirun_on="optirun -b primus"
+        else
+            export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json
+        fi
     fi
     export __NV_PRIME_RENDER_OFFLOAD=1
     export __GLX_VENDOR_LIBRARY_NAME=nvidia

From 04dcd4808ac19f5be34ea57a65230a06a88ba7b9 Mon Sep 17 00:00:00 2001
From: Castro-Fidel <57610802+Castro-Fidel@users.noreply.github.com>
Date: Wed, 19 Aug 2020 22:12:58 +0300
Subject: [PATCH 2/2] Add check optimus-manager

---
 data_from_portwine/scripts/runlib | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/data_from_portwine/scripts/runlib b/data_from_portwine/scripts/runlib
index 55aa2a20..e2dc623f 100755
--- a/data_from_portwine/scripts/runlib
+++ b/data_from_portwine/scripts/runlib
@@ -132,25 +132,21 @@ else
     echo "Use OpenGL mod." 
 fi
 ########################################################################
-export gpu_card=""
-if [ -x "`which optimus-manager 2>/dev/null`" ]; then
-    export gpu_card=`optimus-manager --status | grep Current | cut -f 2 -d':' | sed -e 's/^[[:space:]]*//'`
-fi
 export optirun_on=
+export check_optimus_manager=
 export PW_NVIDIA="$(lspci | grep NVIDIA)" 
-if [[ "$gpu_card" == "nvidia" ]] || [[ ! -z "${PW_NVIDIA}" ]] && [[ "$gpu_card" != "intel" ]]; then
-    if [ -x "`which primusrun 2>/dev/null`" ]; then
-        if [[ "$gpu_card" == "" ]]; then
-          export optirun_on="primusrun"
-        else
-            export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json
-        fi
+if [ -x "`which optimus-manager 2>/dev/null`" ]; then
+    export check_optimus_manager=`optimus-manager --status | grep Current | cut -f 2 -d':' | sed -e 's/^[[:space:]]*//'`
+fi
+if [ ! -z "${PW_NVIDIA}" ] && [ "${check_optimus_manager}" != "intel" ]; then
+    if [ "${check_optimus_manager}" = "nvidia" ]; then
+        export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json
+    elif [ -x "`which primusrun 2>/dev/null`" ]; then
+        export optirun_on="primusrun"
+        export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json 
     elif [ -x "`which optirun 2>/dev/null`" ]; then
-        if [[ "$gpu_card" == "" ]]; then
-            export optirun_on="optirun -b primus"
-        else
-            export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json
-        fi
+        export optirun_on="optirun -b primus"
+        export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json 
     fi
     export __NV_PRIME_RENDER_OFFLOAD=1
     export __GLX_VENDOR_LIBRARY_NAME=nvidia