commit c94db3f270fdfa5f80b2dfa3129b18f45ea3a3c6
parent 7cab7283fc135a820171bd82107ca8e62cda8184
Author: Justinas Grigas <dev@jstnas.com>
Date: Sun, 24 May 2026 23:22:07 +0100
dmenu xresources: improved patch
Diffstat:
1 file changed, 35 insertions(+), 33 deletions(-)
diff --git a/tools.suckless.org/dmenu/patches/xresources/dmenu-xresources-20260510-7175c48.diff b/tools.suckless.org/dmenu/patches/xresources/dmenu-xresources-20260510-7175c48.diff
@@ -1,50 +1,38 @@
-From e0da9966255a9499085555ab43b5277730cf2e02 Mon Sep 17 00:00:00 2001
+From 8320d43fe9634ebe959ac645a108ba913a131ce0 Mon Sep 17 00:00:00 2001
From: Justinas Grigas <dev@jstnas.com>
Date: Sun, 10 May 2026 15:25:31 +0100
Subject: [PATCH] xresources: runtime X Resources loading
---
- config.def.h | 20 +++++++++++++++++-
+ config.def.h | 15 +++++++++++++
dmenu.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 78 insertions(+), 1 deletion(-)
+ 2 files changed, 74 insertions(+)
diff --git a/config.def.h b/config.def.h
-index 1edb647..30daf5a 100644
+index 1edb647..e336034 100644
--- a/config.def.h
+++ b/config.def.h
-@@ -6,7 +6,8 @@ static int topbar = 1; /* -b option; if 0, dmenu appears a
- static const char *fonts[] = {
- "monospace:size=10"
- };
--static const char *prompt = NULL; /* -p option; prompt to the left of input field */
-+/* -p option; prompt to the left of input field */
-+static char *prompt = NULL;
- static const char *colors[SchemeLast][2] = {
- /* fg bg */
- [SchemeNorm] = { "#bbbbbb", "#222222" },
-@@ -21,3 +22,20 @@ static unsigned int lines = 0;
+@@ -21,3 +21,18 @@ static unsigned int lines = 0;
* for example: " /?\"&[]"
*/
static const char worddelimiters[] = " ";
+
-+/*
-+ * Xresources preferences to load at startup
-+ */
++/* X resources to load at startup */
+static const XResPref resources[] = {
-+ /* name type address */
-+ { "dmenu.font", STRING, &fonts[0] },
-+ { "dmenu.prompt", STRING, &prompt },
-+ { "dmenu.foreground", STRING, &colors[SchemeNorm][ColFg] },
-+ { "dmenu.background", STRING, &colors[SchemeNorm][ColBg] },
-+ { "dmenu.foregroundSel", STRING, &colors[SchemeSel][ColFg] },
-+ { "dmenu.backgroundSel", STRING, &colors[SchemeSel][ColBg] },
-+ { "dmenu.foregroundOut", STRING, &colors[SchemeOut][ColFg] },
-+ { "dmenu.backgroundOut", STRING, &colors[SchemeOut][ColBg] },
++ /* name type address */
++ { "dmenu.font", STRING, &fonts[0] },
++ { "dmenu.prompt", STRING, &prompt },
++ { "dmenu.foreground", STRING, &colors[SchemeNorm][ColFg] },
++ { "dmenu.background", STRING, &colors[SchemeNorm][ColBg] },
++ { "dmenu.foregroundSel", STRING, &colors[SchemeSel][ColFg] },
++ { "dmenu.backgroundSel", STRING, &colors[SchemeSel][ColBg] },
++ { "dmenu.foregroundOut", STRING, &colors[SchemeOut][ColFg] },
++ { "dmenu.backgroundOut", STRING, &colors[SchemeOut][ColBg] },
+ { "dmenu.topbar", INTEGER, &topbar },
+ { "dmenu.lines", INTEGER, &lines },
+};
diff --git a/dmenu.c b/dmenu.c
-index 363d19f..0ca41bc 100644
+index 363d19f..bbb160e 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -11,6 +11,7 @@
@@ -55,19 +43,33 @@ index 363d19f..0ca41bc 100644
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
-@@ -52,6 +53,15 @@ static XIC xic;
- static Drw *drw;
- static Clr *scheme[SchemeLast];
+@@ -26,6 +27,7 @@
-+/* Xresources preferences */
-+static XrmDatabase xrdb;
+ /* enums */
+ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
+enum XResType { STRING, INTEGER, FLOAT };
+
+ struct item {
+ char *text;
+@@ -33,6 +35,12 @@ struct item {
+ int out;
+ };
+
+typedef struct {
+ const char *name;
+ enum XResType type;
+ void *dst;
+} XResPref;
+
+ static char text[BUFSIZ] = "";
+ static char *embed;
+ static int bh, mw, mh;
+@@ -52,6 +60,8 @@ static XIC xic;
+ static Drw *drw;
+ static Clr *scheme[SchemeLast];
+
++static XrmDatabase xrdb;
++
#include "config.h"
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;