diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-12-29 18:56:42 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-12-29 18:56:42 +0100 |
commit | 5ab4c7b7525d3cf36777fd1dd77813dc8879dbfc (patch) | |
tree | 3761aadee6e89975443df50171f5fdcd343b8340 | |
parent | 4b506e865a6997fd24b39335a96cfeea7d14c209 (diff) |
Use flatpak specific path for gsr-global-hotkeys
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | src/GlobalHotkeysLinux.cpp | 19 | ||||
-rw-r--r-- | src/main.cpp | 7 |
3 files changed, 22 insertions, 6 deletions
@@ -66,7 +66,7 @@ Make save-video-in-game-folder.sh and notify-saved-name.sh run ~/.config/gpu-scr if the profile is called 4chan. Create a directory of such example scripts, including 4chan webm one. -On nvidia check if suspend fix is applied. If not, show a popup asking the user to apply it (and apply it automatically). This is a requirement before this package is made to a flatpak. +On nvidia check if suspend fix is applied. If not, show a popup asking the user to apply it (and apply it automatically). Show warning when using steam deck or when trying to capture hevc/av1 on amd (the same warnings as gpu screen recorder gtk). diff --git a/src/GlobalHotkeysLinux.cpp b/src/GlobalHotkeysLinux.cpp index b0e8e52..f3ec2b3 100644 --- a/src/GlobalHotkeysLinux.cpp +++ b/src/GlobalHotkeysLinux.cpp @@ -2,6 +2,7 @@ #include <signal.h> #include <sys/wait.h> #include <fcntl.h> +#include <limits.h> #include <string.h> #define PIPE_READ 0 @@ -31,6 +32,14 @@ namespace gsr { } bool GlobalHotkeysLinux::start() { + const bool inside_flatpak = getenv("FLATPAK_ID") != NULL; + const char *user_homepath = getenv("HOME"); + if(!user_homepath) + user_homepath = "/tmp"; + + char gsr_global_hotkeys_flatpak[PATH_MAX]; + snprintf(gsr_global_hotkeys_flatpak, sizeof(gsr_global_hotkeys_flatpak), "%s/.local/share/gpu-screen-recorder/gsr-global-hotkeys", user_homepath); + if(process_id > 0) return false; @@ -51,8 +60,14 @@ namespace gsr { close(pipes[i]); } - const char *args[] = { "gsr-global-hotkeys", NULL }; - execvp(args[0], (char* const*)args); + if(inside_flatpak) { + const char *args[] = { "flatpak-spawn", "--host", "--", gsr_global_hotkeys_flatpak, NULL }; + execvp(args[0], (char* const*)args); + } else { + const char *args[] = { "gsr-global-hotkeys", NULL }; + execvp(args[0], (char* const*)args); + } + perror("execvp"); _exit(127); } else { /* parent */ diff --git a/src/main.cpp b/src/main.cpp index ae08bb8..9c2802b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -177,12 +177,13 @@ int main(int argc, char **argv) { if(argc == 1) { launch_action = LaunchAction::LAUNCH_HIDE; } else if(argc == 2) { - if(strcmp(argv[1], "launch-show") == 0) { + const char *launch_action_opt = argv[1]; + if(strcmp(launch_action_opt, "launch-show") == 0) { launch_action = LaunchAction::LAUNCH_SHOW; - } else if(strcmp(argv[1], "launch-hide") == 0) { + } else if(strcmp(launch_action_opt, "launch-hide") == 0) { launch_action = LaunchAction::LAUNCH_HIDE; } else { - printf("error: invalid action \"%s\", expected \"launch-show\" or \"launch-hide\".\n", argv[1]); + printf("error: invalid action \"%s\", expected \"launch-show\" or \"launch-hide\".\n", launch_action_opt); usage(); } } else { |