aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-06-05 17:34:28 +0200
committerBrian Ashworth <bosrsf04@gmail.com>2019-06-05 14:40:29 -0400
commit900d3287f9b63df6320fa159aa0a842e8e8afd3d (patch)
treef2cb8940f6b06fd90337637cf4626303d9447cae
parentf0f5de9a9e87ca1f0d74e7cbf82ffceba51ffbe6 (diff)
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).
-rw-r--r--swaybar/input.c14
-rw-r--r--swaynag/swaynag.c14
2 files changed, 24 insertions, 4 deletions
diff --git a/swaybar/input.c b/swaybar/input.c
index 92972146..8a83f38f 100644
--- a/swaybar/input.c
+++ b/swaybar/input.c
@@ -67,9 +67,19 @@ void update_cursor(struct swaybar_seat *seat) {
if (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;
- pointer->cursor_theme = wl_cursor_theme_load(NULL, 24 * scale,
- seat->bar->shm);
+ pointer->cursor_theme = wl_cursor_theme_load(
+ cursor_theme, cursor_size * scale, seat->bar->shm);
struct wl_cursor *cursor;
cursor = wl_cursor_theme_get_cursor(pointer->cursor_theme, "left_ptr");
pointer->cursor_image = cursor->images[0];
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c
index 26411ab3..87199a74 100644
--- a/swaynag/swaynag.c
+++ b/swaynag/swaynag.c
@@ -129,8 +129,18 @@ static void update_cursor(struct swaynag *swaynag) {
if (swaynag->pointer.cursor_theme) {
wl_cursor_theme_destroy(swaynag->pointer.cursor_theme);
}
- pointer->cursor_theme = wl_cursor_theme_load(NULL, 24 * swaynag->scale,
- swaynag->shm);
+ 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;
+ }
+ }
+ pointer->cursor_theme = wl_cursor_theme_load(
+ cursor_theme, cursor_size * swaynag->scale, swaynag->shm);
struct wl_cursor *cursor =
wl_cursor_theme_get_cursor(pointer->cursor_theme, "left_ptr");
pointer->cursor_image = cursor->images[0];