clients: configure cursor theme from XCURSOR_* env

If XCURSOR_THEME or XCURSOR_SIZE is set, use it as the cursor theme
or cursor size.

This is similar to what Qt and some X11 apps do.
This commit is contained in:
emersion 2018-10-10 09:46:12 +02:00 committed by Daniel Stone
parent 1f3fae2f1a
commit 807cd2e589
1 changed files with 7 additions and 3 deletions

View File

@ -1340,16 +1340,20 @@ create_cursors(struct display *display)
const char *config_file;
struct weston_config *config;
struct weston_config_section *s;
int size;
int size = 32;
char *theme = NULL;
unsigned int i, j;
struct wl_cursor *cursor;
theme = getenv("XCURSOR_THEME");
if (getenv("XCURSOR_SIZE"))
size = atoi(getenv("XCURSOR_SIZE"));
config_file = weston_config_get_name_from_env();
config = weston_config_parse(config_file);
s = weston_config_get_section(config, "shell", NULL, NULL);
weston_config_section_get_string(s, "cursor-theme", &theme, NULL);
weston_config_section_get_int(s, "cursor-size", &size, 32);
weston_config_section_get_string(s, "cursor-theme", &theme, theme);
weston_config_section_get_int(s, "cursor-size", &size, size);
weston_config_destroy(config);
display->cursor_theme = wl_cursor_theme_load(theme, size, display->shm);