mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Revert "Change name of flatpak systemd service"
This reverts commit b865f5cae3.
This commit is contained in:
@@ -17,5 +17,9 @@ namespace gsr {
|
|||||||
pid_t exec_program(const char **args, int *read_fd);
|
pid_t exec_program(const char **args, int *read_fd);
|
||||||
// Arguments ending with NULL. Returns the exit status of the program or -1 on error
|
// Arguments ending with NULL. Returns the exit status of the program or -1 on error
|
||||||
int exec_program_get_stdout(const char **args, std::string &result);
|
int exec_program_get_stdout(const char **args, std::string &result);
|
||||||
|
// Arguments ending with NULL. Returns the exit status of the program or -1 on error.
|
||||||
|
// This works the same as |exec_program_get_stdout|, except on flatpak where this runs the program on the
|
||||||
|
// host machine with flatpak-spawn --host
|
||||||
|
int exec_program_on_host_get_stdout(const char **args, std::string &result);
|
||||||
pid_t pidof(const char *process_name);
|
pid_t pidof(const char *process_name);
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,15 @@ namespace gsr {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int count_num_args(const char **args) {
|
||||||
|
int num_args = 0;
|
||||||
|
while(*args) {
|
||||||
|
++num_args;
|
||||||
|
++args;
|
||||||
|
}
|
||||||
|
return num_args;
|
||||||
|
}
|
||||||
|
|
||||||
bool exec_program_daemonized(const char **args) {
|
bool exec_program_daemonized(const char **args) {
|
||||||
/* 1 argument */
|
/* 1 argument */
|
||||||
if(args[0] == nullptr)
|
if(args[0] == nullptr)
|
||||||
@@ -143,6 +152,30 @@ namespace gsr {
|
|||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int exec_program_on_host_get_stdout(const char **args, std::string &result) {
|
||||||
|
if(count_num_args(args) > 64 - 3) {
|
||||||
|
fprintf(stderr, "Error: too many arguments when trying to launch \"%s\"\n", args[0]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool inside_flatpak = getenv("FLATPAK_ID") != NULL;
|
||||||
|
if(inside_flatpak) {
|
||||||
|
// Assumes programs wont need more than 64 - 3 args
|
||||||
|
const char *modified_args[64] = { "flatpak-spawn", "--host", "--" };
|
||||||
|
for(int i = 3; i < 64; ++i) {
|
||||||
|
const char *arg = args[i - 3];
|
||||||
|
if(!arg) {
|
||||||
|
modified_args[i] = nullptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
modified_args[i] = arg;
|
||||||
|
}
|
||||||
|
return exec_program_get_stdout(modified_args, result);
|
||||||
|
} else {
|
||||||
|
return exec_program_get_stdout(args, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// |output_buffer| should be at least PATH_MAX in size
|
// |output_buffer| should be at least PATH_MAX in size
|
||||||
bool read_cmdline_arg0(const char *filepath, char *output_buffer, int output_buffer_size) {
|
bool read_cmdline_arg0(const char *filepath, char *output_buffer, int output_buffer_size) {
|
||||||
output_buffer[0] = '\0';
|
output_buffer[0] = '\0';
|
||||||
|
|||||||
@@ -75,17 +75,9 @@ namespace gsr {
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const char *args[] = { "systemctl", enable ? "enable" : "disable", "--user", "gpu-screen-recorder-ui", nullptr };
|
||||||
std::string stdout_str;
|
std::string stdout_str;
|
||||||
int exit_status = 0;
|
const int exit_status = exec_program_on_host_get_stdout(args, stdout_str);
|
||||||
const bool inside_flatpak = getenv("FLATPAK_ID") != NULL;
|
|
||||||
if(inside_flatpak) {
|
|
||||||
const char *args[] = { "flatpak-spawn", "--host", "--", "systemctl", enable ? "enable" : "disable", "--user", "gpu-screen-recorder-ui-flatpak", nullptr };
|
|
||||||
exit_status = exec_program_get_stdout(args, stdout_str);
|
|
||||||
} else {
|
|
||||||
const char *args[] = { "systemctl", enable ? "enable" : "disable", "--user", "gpu-screen-recorder-ui", nullptr };
|
|
||||||
exit_status = exec_program_get_stdout(args, stdout_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(on_startup_changed)
|
if(on_startup_changed)
|
||||||
on_startup_changed(enable, exit_status);
|
on_startup_changed(enable, exit_status);
|
||||||
};
|
};
|
||||||
@@ -115,17 +107,9 @@ namespace gsr {
|
|||||||
else
|
else
|
||||||
tint_color_radio_button_ptr->set_selected_item(config.main_config.tint_color);
|
tint_color_radio_button_ptr->set_selected_item(config.main_config.tint_color);
|
||||||
|
|
||||||
|
const char *args[] = { "systemctl", "is-enabled", "--quiet", "--user", "gpu-screen-recorder-ui", nullptr };
|
||||||
std::string stdout_str;
|
std::string stdout_str;
|
||||||
int exit_status = 0;
|
const int exit_status = exec_program_on_host_get_stdout(args, stdout_str);
|
||||||
const bool inside_flatpak = getenv("FLATPAK_ID") != NULL;
|
|
||||||
if(inside_flatpak) {
|
|
||||||
const char *args[] = { "flatpak-spawn", "--host", "--", "systemctl", "is-enabled", "--quiet", "--user", "gpu-screen-recorder-ui", nullptr };
|
|
||||||
exit_status = exec_program_get_stdout(args, stdout_str);
|
|
||||||
} else {
|
|
||||||
const char *args[] = { "systemctl", "is-enabled", "--quiet", "--user", "gpu-screen-recorder-ui", nullptr };
|
|
||||||
exit_status = exec_program_get_stdout(args, stdout_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
startup_radio_button_ptr->set_selected_item(exit_status == 0 ? "start_on_system_startup" : "dont_start_on_system_startup", false, false);
|
startup_radio_button_ptr->set_selected_item(exit_status == 0 ? "start_on_system_startup" : "dont_start_on_system_startup", false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user