From 23af3c55957ef16bb61dee6bf7376e810c0c03dc Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sat, 14 Mar 2026 12:50:31 +0800 Subject: [PATCH] opt: auto sync XCURSOR_SIZE and XCURSOR_THEME env from config --- docs/configuration/basics.md | 4 ++-- src/mango.c | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/docs/configuration/basics.md b/docs/configuration/basics.md index 22b2679..7afa343 100644 --- a/docs/configuration/basics.md +++ b/docs/configuration/basics.md @@ -60,8 +60,8 @@ You can define environment variables directly within your config file. These are > **Warning:** Environment variables defined here will be **reset** every time you reload the configuration. ```ini -env=GTK_THEME,Adwaita:dark -env=XCURSOR_SIZE,24 +env=QT_IM_MODULES,wayland;fcitx +env=XMODIFIERS,@im=fcitx ``` ## Autostart diff --git a/src/mango.c b/src/mango.c index aedf1d6..915c47b 100644 --- a/src/mango.c +++ b/src/mango.c @@ -912,8 +912,13 @@ static KeyMode keymode = { .isdefault = true, }; -static char *env_vars[] = {"DISPLAY", "WAYLAND_DISPLAY", "XDG_CURRENT_DESKTOP", - "XDG_SESSION_TYPE", NULL}; +static char *env_vars[] = {"DISPLAY", + "WAYLAND_DISPLAY", + "XDG_CURRENT_DESKTOP", + "XDG_SESSION_TYPE", + "XCURSOR_THEME", + "XCURSOR_SIZE", + NULL}; static struct { enum wp_cursor_shape_device_v1_shape shape; struct wlr_surface *surface; @@ -5463,7 +5468,6 @@ void handle_print_status(struct wl_listener *listener, void *data) { void setup(void) { - setenv("XCURSOR_SIZE", "24", 1); setenv("XDG_CURRENT_DESKTOP", "mango", 1); parse_config(); @@ -5653,6 +5657,18 @@ void setup(void) { cursor_mgr = wlr_xcursor_manager_create(config.cursor_theme, config.cursor_size); + if (config.cursor_size > 0) { + char size_str[16]; + snprintf(size_str, sizeof(size_str), "%d", config.cursor_size); + setenv("XCURSOR_SIZE", size_str, 1); + } else { + setenv("XCURSOR_SIZE", "24", 1); + } + + if (config.cursor_theme) { + setenv("XCURSOR_THEME", config.cursor_theme, 1); + } + /* * wlr_cursor *only* displays an image on screen. It does not move * around when the pointer moves. However, we can attach input devices