From 365f81643253e5005f1fac2e6119be3bcec01261 Mon Sep 17 00:00:00 2001
From: egorguslyan <egorguslyan@gmail.com>
Date: Sat, 4 Dec 2021 16:34:17 +0300
Subject: [PATCH] allow specify cursor theme and size
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Leonardo Hernández Hernández <leohdz172@proton.me>
---
 config.def.h | 2 ++
 dwl.c        | 8 ++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/config.def.h b/config.def.h
index 93b2fdc..cdf11b5 100644
--- a/config.def.h
+++ b/config.def.h
@@ -14,6 +14,8 @@ static const unsigned int gappih           = 10; /* horiz inner gap between wind
 static const unsigned int gappiv           = 10; /* vert inner gap between windows */
 static const unsigned int gappoh           = 10; /* horiz outer gap between windows and screen edge */
 static const unsigned int gappov           = 10; /* vert outer gap between windows and screen edge */
+static const char *cursortheme             = NULL; /* theme from /usr/share/cursors/xorg-x11 or ${XCURSOR_PATH} */
+static const char cursorsize[]             = "24";
 static const float bordercolor[]           = COLOR(0x444444ff);
 static const float focuscolor[]            = COLOR(0x005577ff);
 static const float urgentcolor[]           = COLOR(0xff0000ff);
diff --git a/dwl.c b/dwl.c
index 47c3a23..62a6838 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2863,8 +2863,12 @@ setup(void)
 	 * Xcursor themes to source cursor images from and makes sure that cursor
 	 * images are available at all scale factors on the screen (necessary for
 	 * HiDPI support). Scaled cursors will be loaded with each output. */
-	cursor_mgr = wlr_xcursor_manager_create(NULL, 24);
-	setenv("XCURSOR_SIZE", "24", 1);
+	cursor_mgr = wlr_xcursor_manager_create(cursortheme, atoi(cursorsize));
+	setenv("XCURSOR_SIZE", cursorsize, 1);
+	if (cursortheme)
+		setenv("XCURSOR_THEME", cursortheme, 1);
+	else
+		unsetenv("XCURSOR_THEME");
 
 	/*
 	 * wlr_cursor *only* displays an image on screen. It does not move around