opt: auto sync XCURSOR_SIZE and XCURSOR_THEME env from config

This commit is contained in:
DreamMaoMao 2026-03-14 12:50:31 +08:00
parent b0ec0b4275
commit 23af3c5595
2 changed files with 21 additions and 5 deletions

View file

@ -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

View file

@ -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