nixpkgs-suyu/pkgs/applications/video/gpu-screen-recorder/fix-nvfbc-check.patch
2022-03-22 23:04:20 -04:00

38 lines
1.1 KiB
Diff

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) {