aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2025-05-02 12:32:08 +0200
committerdec05eba <dec05eba@protonmail.com>2025-05-02 12:32:08 +0200
commit180a3b73dbab2f586c53f9e5f044ab88aca95014 (patch)
tree48e5b5e70f0ef1ea97894270b3f084d7ea0acd8d /src/main.cpp
parentac1d57e8ba5059608b32ceeed8d91cf509a26d86 (diff)
Fix ui being on wrong monitor/focused monitor capture incorrect on kde plasma wayland when vrr is enabled (fallback to window creation & window position trick)HEADmaster
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 19a23c7..31ec8ff 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -159,6 +159,21 @@ static bool is_flatpak() {
return getenv("FLATPAK_ID") != nullptr;
}
+static void set_display_server_environment_variables() {
+ // Some users dont have properly setup environments (no display manager that does systemctl --user import-environment DISPLAY WAYLAND_DISPLAY)
+ const char *display = getenv("DISPLAY");
+ if(!display) {
+ display = ":0";
+ setenv("DISPLAY", display, true);
+ }
+
+ const char *wayland_display = getenv("WAYLAND_DISPLAY");
+ if(!wayland_display) {
+ wayland_display = "wayland-1";
+ setenv("WAYLAND_DISPLAY", wayland_display, true);
+ }
+}
+
static void usage() {
printf("usage: gsr-ui [action]\n");
printf("OPTIONS:\n");
@@ -203,18 +218,7 @@ int main(int argc, char **argv) {
usage();
}
- // Some users dont have properly setup environments (no display manager that does systemctl --user import-environment DISPLAY WAYLAND_DISPLAY)
- const char *display = getenv("DISPLAY");
- if(!display) {
- display = ":0";
- setenv("DISPLAY", display, true);
- }
-
- const char *wayland_display = getenv("WAYLAND_DISPLAY");
- if(!wayland_display) {
- wayland_display = "wayland-1";
- setenv("WAYLAND_DISPLAY", wayland_display, true);
- }
+ set_display_server_environment_variables();
// TODO: This is a shitty method to detect if multiple instances of gsr-ui is running but this will work properly even in flatpak
// that uses pid sandboxing. Replace this with a better method once we no longer rely on linux global hotkeys on some platform.