From 77fff8934b5a92dcf30a016aa1daa9c927776128 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Fri, 10 Jul 2026 08:04:56 +0800 Subject: [PATCH] fix: dont set display env before x11 backend create --- src/config/parse_config.h | 16 ++++++++++++++-- src/mango.c | 4 +++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 236953fc..54da5cc1 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -1326,12 +1326,23 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, return func; } -void set_env() { +void set_env_without_display() { for (int32_t i = 0; i < config.env_count; i++) { + if (strcmp(config.env[i]->type, "DISPLAY") == 0) { + continue; // Skip setting DISPLAY + } setenv(config.env[i]->type, config.env[i]->value, 1); } } +void set_env_display() { + for (int32_t i = 0; i < config.env_count; i++) { + if (strcmp(config.env[i]->type, "DISPLAY") == 0) { + setenv("DISPLAY", config.env[i]->value, 1); + } + } +} + void run_exec() { Arg arg; @@ -4334,7 +4345,8 @@ void reset_option(void) { handlecursoractivity(); reset_keyboard_layout(); reset_blur_params(); - set_env(); + set_env_without_display(); + set_env_display(); run_exec(); reapply_cursor_style(); diff --git a/src/mango.c b/src/mango.c index 602dbf07..5340d4c9 100644 --- a/src/mango.c +++ b/src/mango.c @@ -5560,6 +5560,8 @@ run(char *startup_cmd) { die("startup: display_add_socket_auto"); setenv("WAYLAND_DISPLAY", socket, 1); + set_env_display(); + /* Start the backend. This will enumerate outputs and inputs, become the * DRM master, etc */ if (!wlr_backend_start(backend)) @@ -6150,7 +6152,7 @@ void setup(void) { } init_baked_points(); - set_env(); + set_env_without_display(); int32_t drm_fd, i; int32_t sig[] = {SIGCHLD, SIGINT,