mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-05-06 23:06:24 +09:00
Detect multiple instances of gsr-ui by detecting virtual keyboard presence instead. This works in flatpak
This commit is contained in:
29
src/main.cpp
29
src/main.cpp
@@ -133,6 +133,24 @@ static std::unique_ptr<gsr::GlobalHotkeysLinux> register_linux_hotkeys(gsr::Over
|
|||||||
return global_hotkeys;
|
return global_hotkeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_gsr_ui_virtual_keyboard_running() {
|
||||||
|
FILE *f = fopen("/proc/bus/input/devices", "rb");
|
||||||
|
if(!f)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool virtual_keyboard_running = false;
|
||||||
|
char line[1024];
|
||||||
|
while(fgets(line, sizeof(line), f)) {
|
||||||
|
if(strstr(line, "gsr-ui virtual keyboard")) {
|
||||||
|
virtual_keyboard_running = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
return virtual_keyboard_running;
|
||||||
|
}
|
||||||
|
|
||||||
static void usage() {
|
static void usage() {
|
||||||
printf("usage: gsr-ui [action]\n");
|
printf("usage: gsr-ui [action]\n");
|
||||||
printf("OPTIONS:\n");
|
printf("OPTIONS:\n");
|
||||||
@@ -171,12 +189,19 @@ int main(int argc, char **argv) {
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
const pid_t gsr_ui_pid = gsr::pidof("gsr-ui");
|
// TODO: This is a shitty method to detect if multiple instances of gsr-ui is running but this will work properly even in flatpak
|
||||||
if(gsr_ui_pid != -1) {
|
// that uses pid sandboxing. Replace this with a better method once we no longer rely on linux global hotkeys on some platform.
|
||||||
|
if(is_gsr_ui_virtual_keyboard_running()) {
|
||||||
const char *args[] = { "gsr-notify", "--text", "Another instance of GPU Screen Recorder UI is already running", "--timeout", "5.0", "--icon-color", "ff0000", "--bg-color", "ff0000", nullptr };
|
const char *args[] = { "gsr-notify", "--text", "Another instance of GPU Screen Recorder UI is already running", "--timeout", "5.0", "--icon-color", "ff0000", "--bg-color", "ff0000", nullptr };
|
||||||
gsr::exec_program_daemonized(args);
|
gsr::exec_program_daemonized(args);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
// const pid_t gsr_ui_pid = gsr::pidof("gsr-ui");
|
||||||
|
// if(gsr_ui_pid != -1) {
|
||||||
|
// const char *args[] = { "gsr-notify", "--text", "Another instance of GPU Screen Recorder UI is already running", "--timeout", "5.0", "--icon-color", "ff0000", "--bg-color", "ff0000", nullptr };
|
||||||
|
// gsr::exec_program_daemonized(args);
|
||||||
|
// return 1;
|
||||||
|
// }
|
||||||
|
|
||||||
// Cant get window texture when prime-run is used
|
// Cant get window texture when prime-run is used
|
||||||
disable_prime_run();
|
disable_prime_run();
|
||||||
|
|||||||
Reference in New Issue
Block a user