diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-01-20 23:11:00 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-01-20 23:11:00 +0100 |
commit | 47ada4d79844d9a98d9689d0de0c92864e0fc372 (patch) | |
tree | 1325fd3061e78a194b3db0be848a06928fdacce9 /tools/gsr-global-hotkeys/main.c | |
parent | 92401d8bc8fa3cbc8017936eb1d18280199942e0 (diff) |
Add option to save replay with controller (double-click share button), allow prime-run on wayland
Diffstat (limited to 'tools/gsr-global-hotkeys/main.c')
-rw-r--r-- | tools/gsr-global-hotkeys/main.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/gsr-global-hotkeys/main.c b/tools/gsr-global-hotkeys/main.c index b64d60f..d05ca5f 100644 --- a/tools/gsr-global-hotkeys/main.c +++ b/tools/gsr-global-hotkeys/main.c @@ -116,6 +116,24 @@ static x11_context setup_x11_context(void) { return x_context; } +static bool is_gsr_global_hotkeys_already_running(void) { + 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; +} + int main(int argc, char **argv) { keyboard_grab_type grab_type = KEYBOARD_GRAB_TYPE_ALL; if(argc == 2) { @@ -135,6 +153,11 @@ int main(int argc, char **argv) { return 1; } + if(is_gsr_global_hotkeys_already_running()) { + fprintf(stderr, "Error: gsr-global-hotkeys is already running\n"); + return 1; + } + x11_context x_context = setup_x11_context(); const uid_t user_id = getuid(); |