From 9d80d674f4669fef5d03e20c3f436d494ccfa83f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 28 Nov 2023 22:37:56 +0100 Subject: Run -sc with flatpak-spawn if inside flatpak --- src/main.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 6b8c374..6966a34 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -914,7 +914,23 @@ static AVStream* create_stream(AVFormatContext *av_format_context, AVCodecContex } static void run_recording_saved_script_async(const char *script_file, const char *video_file, const char *type) { - const char *args[] = { script_file, video_file, type, NULL }; + const char *args[6]; + const bool inside_flatpak = getenv("FLATPAK_ID") != NULL; + + if(inside_flatpak) { + args[0] = "flatpak-spawn"; + args[1] = "--host"; + args[2] = script_file; + args[3] = video_file; + args[4] = type; + args[5] = NULL; + } else { + args[0] = script_file; + args[1] = video_file; + args[2] = type; + args[3] = NULL; + } + pid_t pid = fork(); if(pid == -1) { perror(script_file); @@ -925,7 +941,7 @@ static void run_recording_saved_script_async(const char *script_file, const char pid_t second_child = fork(); if(second_child == 0) { // child - execvp(script_file, (char* const*)args); + execvp(args[0], (char* const*)args); perror(script_file); _exit(127); } else if(second_child != -1) { // parent -- cgit v1.2.3