From a9767ad2f742dc37896b3cae07d3ced80df28682 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 17 Jul 2016 10:59:03 -0400 Subject: [PATCH] Allow users to customize the cursor on clients This also sets the default size to 16 and documents all of the other environment variables in use in sway(1). --- sway/sway.1.txt | 38 ++++++++++++++++++++++++++++++++++++++ wayland/window.c | 12 +++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/sway/sway.1.txt b/sway/sway.1.txt index f62e27f4..0e503d2e 100644 --- a/sway/sway.1.txt +++ b/sway/sway.1.txt @@ -79,6 +79,44 @@ the location of your choosing and start there. For information on the config file format, see **sway**(5). +Environment +----------- + +The following environment variables have an effect on sway: + +*SWAY_CURSOR_THEME*:: + Specifies the name of the cursor theme to use. + +*SWAY_CURSOR_SIZE*:: + Specifies the size of the cursor to use. + +*SWAYSOCK*:: + Specifies the path to the sway IPC socket. + +*WLC_DRM_DEVICE*:: + Specifies the device to use in DRM mode. + +*WLC_SHM*:: + Set 1 to force EGL clients to use shared memory. + +*WLC_OUTPUTS*:: + Number of fake outputs to use when running in X11 mode. + +*WLC_XWAYLAND*:: + Set to 0 to disable Xwayland support. + +*WLC_LIBINPUT*:: + Set to 1 to force libinput (even in X11 mode). + +*WLC_REPEAT_DELAY*:: + Configures the keyboard repeat delay. + +*WLC_REPEAT_RATE*:: + Configures the keyboard repeat rate. + +*XKB_DEFAULT_LAYOUT*, *XKB_DEFAULT_VARIANT*, *XKB_DEFAULT_OPTIONS*:: + Configures the xkb keyboard settings. See xkeyboard-config(7). + Authors ------- diff --git a/wayland/window.c b/wayland/window.c index 9bc0d4a2..3f48d39f 100644 --- a/wayland/window.c +++ b/wayland/window.c @@ -112,7 +112,17 @@ struct window *window_setup(struct registry *registry, uint32_t width, uint32_t get_next_buffer(window); if (registry->pointer) { - window->cursor.cursor_theme = wl_cursor_theme_load("default", 32, registry->shm); // TODO: let you customize this + char *cursor_theme = getenv("SWAY_CURSOR_THEME"); + if (!cursor_theme) { + cursor_theme = "default"; + } + char *cursor_size = getenv("SWAY_CURSOR_SIZE"); + if (!cursor_size) { + cursor_size = "16"; + } + + window->cursor.cursor_theme = wl_cursor_theme_load(cursor_theme, + atoi(cursor_size), registry->shm); window->cursor.cursor = wl_cursor_theme_get_cursor(window->cursor.cursor_theme, "left_ptr"); window->cursor.surface = wl_compositor_create_surface(registry->compositor);