swaybar/nag: use xcursor theme defined by XCURSOR_THEME/SIZE

If the XCURSOR_THEME and/or XCURSOR_SIZE environment variables are
set, use the theme and size they define.

If they're not set, use the same defaults as before (system default
theme, size=24).
master
Daniel Eklöf 6 years ago committed by Brian Ashworth
parent f0f5de9a9e
commit 900d3287f9

@ -67,9 +67,19 @@ void update_cursor(struct swaybar_seat *seat) {
if (pointer->cursor_theme) { if (pointer->cursor_theme) {
wl_cursor_theme_destroy(pointer->cursor_theme); wl_cursor_theme_destroy(pointer->cursor_theme);
} }
const char *cursor_theme = getenv("XCURSOR_THEME");
unsigned cursor_size = 24;
const char *env_cursor_size = getenv("XCURSOR_SIZE");
if (env_cursor_size) {
char *end;
unsigned size = strtoul(env_cursor_size, &end, 10);
if (!*end) {
cursor_size = size;
}
}
int scale = pointer->current ? pointer->current->scale : 1; int scale = pointer->current ? pointer->current->scale : 1;
pointer->cursor_theme = wl_cursor_theme_load(NULL, 24 * scale, pointer->cursor_theme = wl_cursor_theme_load(
seat->bar->shm); cursor_theme, cursor_size * scale, seat->bar->shm);
struct wl_cursor *cursor; struct wl_cursor *cursor;
cursor = wl_cursor_theme_get_cursor(pointer->cursor_theme, "left_ptr"); cursor = wl_cursor_theme_get_cursor(pointer->cursor_theme, "left_ptr");
pointer->cursor_image = cursor->images[0]; pointer->cursor_image = cursor->images[0];

@ -129,8 +129,18 @@ static void update_cursor(struct swaynag *swaynag) {
if (swaynag->pointer.cursor_theme) { if (swaynag->pointer.cursor_theme) {
wl_cursor_theme_destroy(swaynag->pointer.cursor_theme); wl_cursor_theme_destroy(swaynag->pointer.cursor_theme);
} }
pointer->cursor_theme = wl_cursor_theme_load(NULL, 24 * swaynag->scale, const char *cursor_theme = getenv("XCURSOR_THEME");
swaynag->shm); unsigned cursor_size = 24;
const char *env_cursor_size = getenv("XCURSOR_SIZE");
if (env_cursor_size) {
char *end;
unsigned size = strtoul(env_cursor_size, &end, 10);
if (!*end) {
cursor_size = size;
}
}
pointer->cursor_theme = wl_cursor_theme_load(
cursor_theme, cursor_size * swaynag->scale, swaynag->shm);
struct wl_cursor *cursor = struct wl_cursor *cursor =
wl_cursor_theme_get_cursor(pointer->cursor_theme, "left_ptr"); wl_cursor_theme_get_cursor(pointer->cursor_theme, "left_ptr");
pointer->cursor_image = cursor->images[0]; pointer->cursor_image = cursor->images[0];

Loading…
Cancel
Save