about summary refs log tree commit diff
path: root/pkgs/applications/video/gpu-screen-recorder/fix-nvfbc-check.patch
blob: bd0d7111c80a332f85c6453173f2e39f3b4a06d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
diff --git a/build.sh b/build.sh
index 05603db..8c38b31 100755
--- a/build.sh
+++ b/build.sh
@@ -2,5 +2,5 @@
 
 dependencies="gtk+-3.0 x11 xrandr libpulse"
 includes="$(pkg-config --cflags $dependencies)"
-libs="$(pkg-config --libs $dependencies)"
+libs="$(pkg-config --libs $dependencies) -ldl"
 g++ -o gpu-screen-recorder-gtk -O2 src/main.cpp -s $includes $libs
diff --git a/src/main.cpp b/src/main.cpp
index ae2078f..9dcdce1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,6 +15,7 @@
 #include <pwd.h>
 #include <libgen.h>
 #include <functional>
+#include <dlfcn.h>
 
 typedef struct {
     Display *display;
@@ -830,7 +831,13 @@ static void audio_input_change_callback(GtkComboBox *widget, gpointer userdata)
 }
 
 static bool is_nv_fbc_installed() {
-    return access("/usr/lib/libnvidia-fbc.so.1", F_OK) == 0 || access("/usr/local/lib/libnvidia-fbc.so.1", F_OK) == 0;
+    auto handle = dlopen("libnvidia-fbc.so.1", RTLD_LAZY);
+    if (handle) {
+        dlclose(handle);
+        return true;
+    } else {
+        return false;
+    }
 }
 
 static GtkWidget* create_common_settings_page(GtkStack *stack, GtkApplication *app) {