diff options
author | dec05eba <dec05eba@protonmail.com> | 2023-11-28 22:37:56 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2023-11-28 22:37:56 +0100 |
commit | 9d80d674f4669fef5d03e20c3f436d494ccfa83f (patch) | |
tree | 8dd54231532bfea482a2d22a6c62057a909d50e9 /src/main.cpp | |
parent | a855c707e58fad7e41a2dbe7d079614df2ad2ca1 (diff) |
Run -sc with flatpak-spawn if inside flatpak
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
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 |