URI:
       dmenu xresources: refined - sites - public wiki contents of suckless.org
  HTML git clone git://git.suckless.org/sites
   DIR Log
   DIR Files
   DIR Refs
       ---
   DIR commit ba9f7f4ee4e546e4feda9b9d6e371cf049f49f3b
   DIR parent fd732314bd4609138fa04f7d8ed3b57bff8dcb5e
  HTML Author: Justinas Grigas <dev@jstnas.com>
       Date:   Sun, 10 May 2026 16:36:05 +0100
       
       dmenu xresources: refined
       
       Spent a couple of days looking at all the xresources patches to make
       them good
       
       Diffstat:
         D tools.suckless.org/dmenu/patches/x… |      21 ---------------------
         A tools.suckless.org/dmenu/patches/x… |     145 +++++++++++++++++++++++++++++++
         R tools.suckless.org/dmenu/patches/x… |       0 
         M tools.suckless.org/dmenu/patches/x… |      69 +++++++++++++++++--------------
       
       4 files changed, 184 insertions(+), 51 deletions(-)
       ---
   DIR diff --git a/tools.suckless.org/dmenu/patches/xresources-alt/index.md b/tools.suckless.org/dmenu/patches/xresources-alt/index.md
       @@ -1,21 +0,0 @@
       -xresources
       -==========
       -
       -Description
       ------------
       -This patch is actually a xresources patch for dwm, applied to dmenu.
       -
       -The patch add the ability to configure dmenu via Xresources by using arbitrary
       -resources, not specific ones. Xresources values override default settings and can be 
       -overriden by command line arguments.
       -
       -All thanks should go to the authors of xresources patch for dwm, xresources and 
       -xrdb patches for st.
       -
       -Download
       ---------
       -* [dmenu-xresources-alt-5.0.diff](dmenu-xresources-alt-5.0.diff)
       -
       -Authors
       --------
       -* Vadim Zyamalov
   DIR 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
       @@ -0,0 +1,145 @@
       +From e0da9966255a9499085555ab43b5277730cf2e02 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 +++++++++++++++++-
       + dmenu.c      | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++
       + 2 files changed, 78 insertions(+), 1 deletion(-)
       +
       +diff --git a/config.def.h b/config.def.h
       +index 1edb647..30daf5a 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;
       +  * for example: " /?\"&[]"
       +  */
       + static const char worddelimiters[] = " ";
       ++
       ++/*
       ++ * Xresources preferences 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] },
       ++        { "dmenu.topbar",        INTEGER, &topbar },
       ++        { "dmenu.lines",         INTEGER, &lines },
       ++};
       +diff --git a/dmenu.c b/dmenu.c
       +index 363d19f..0ca41bc 100644
       +--- a/dmenu.c
       ++++ b/dmenu.c
       +@@ -11,6 +11,7 @@
       + #include <X11/Xlib.h>
       + #include <X11/Xatom.h>
       + #include <X11/Xutil.h>
       ++#include <X11/Xresource.h>
       + #ifdef XINERAMA
       + #include <X11/extensions/Xinerama.h>
       + #endif
       +@@ -52,6 +53,15 @@ static XIC xic;
       + static Drw *drw;
       + static Clr *scheme[SchemeLast];
       + 
       ++/* Xresources preferences */
       ++static XrmDatabase xrdb;
       ++enum XResType { STRING, INTEGER, FLOAT };
       ++typedef struct {
       ++        const char *name;
       ++        enum XResType type;
       ++        void *dst;
       ++} XResPref;
       ++
       + #include "config.h"
       + 
       + static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
       +@@ -107,6 +117,7 @@ cleanup(void)
       +                 free(items[i].text);
       +         free(items);
       +         drw_free(drw);
       ++        XrmDestroyDatabase(xrdb);
       +         XSync(dpy, False);
       +         XCloseDisplay(dpy);
       + }
       +@@ -718,12 +729,60 @@ usage(void)
       +             "             [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
       + }
       + 
       ++void
       ++xresload(const XResPref *resource)
       ++{
       ++        char *type;
       ++        XrmValue ret;
       ++
       ++        if (!XrmGetResource(xrdb, resource->name, NULL, &type, &ret))
       ++                return;
       ++        if (!ret.addr || strncmp(type, "String", sizeof("String")))
       ++                return;
       ++
       ++        switch (resource->type) {
       ++        case STRING:
       ++                *(char **)resource->dst = ret.addr;
       ++                break;
       ++        case INTEGER:
       ++                *(int *)resource->dst = strtoul(ret.addr, NULL, 10);
       ++                break;
       ++        case FLOAT:
       ++                *(float *)resource->dst = strtof(ret.addr, NULL);
       ++                break;
       ++        }
       ++}
       ++
       ++void
       ++xresupdate(void)
       ++{
       ++        Display *display;
       ++        char *resm;
       ++        const XResPref *p;
       ++
       ++        display = XOpenDisplay(NULL);
       ++        if (!display)
       ++                return;
       ++        resm = XResourceManagerString(display);
       ++        if (resm) {
       ++                xrdb = XrmGetStringDatabase(resm);
       ++                if (xrdb) {
       ++                        for (p = resources; p < resources + LENGTH(resources); ++p)
       ++                                xresload(p);
       ++                }
       ++        }
       ++        XCloseDisplay(display);
       ++}
       ++
       + int
       + main(int argc, char *argv[])
       + {
       +         XWindowAttributes wa;
       +         int i, fast = 0;
       + 
       ++        XrmInitialize();
       ++        xresupdate();
       ++
       +         for (i = 1; i < argc; i++)
       +                 /* these options take no arguments */
       +                 if (!strcmp(argv[i], "-v")) {      /* prints version information */
       +-- 
       +2.53.0
       +
   DIR diff --git a/tools.suckless.org/dmenu/patches/xresources-alt/dmenu-xresources-alt-5.0.diff b/tools.suckless.org/dmenu/patches/xresources/dmenu-xresources-alt-5.0.diff
   DIR diff --git a/tools.suckless.org/dmenu/patches/xresources/index.md b/tools.suckless.org/dmenu/patches/xresources/index.md
       @@ -1,30 +1,39 @@
       -xresources
       -==========
       -
       -Description
       ------------
       -This patch was originally made by Michał Lemke has been slightly modified to
       -work with dmenu 4.9.
       -
       -This patch adds the ability to configure dmenu via Xresources. At startup,
       -dmenu will read and apply the change to the applicable resource. Below are the
       -resources that can be changed and what they change:
       -
       -- dmenu.font          : font or font set
       -- dmenu.background    : normal background color
       -- dmenu.foreground    : normal foreground color
       -- dmenu.selbackground : selected background color
       -- dmenu.selforeground : selected foreground color
       -
       -Note: Values in Xresources will override values in config.h, but will be
       -overridden by command line arguments.
       -Download
       ---------
       -* [dmenu-xresources-4.9.diff](dmenu-xresources-4.9.diff)
       -
       -Authors
       --------
       -* Michał Lemke - @melek on [Bitbucket](https://bitbucket.org/melek/dmenu2/)
       -* Pratik Bhusal - dmenu-xresources-4.9 port
       -* Nihal Jere <nihal@nihaljere.xyz> (20200302)
       -* Francesco Minnocci <ad17fmin@uwcad.it> - command line parameters fix
       +# xresources
       +
       +Runtime configuration using X Resources.
       +
       +## Description
       +
       +This patch adds Xresources support to dmenu. At startup, dmenu reads the
       +relevant X resources and applies them at runtime. A declarative array defines
       +the resources, making the patch easy to extend with more settings.
       +dmenu recognizes the following resources by default:
       +
       +- `dmenu.font`: font or font set
       +- `dmenu.prompt`: prompt string
       +- `dmenu.background`: normal background color
       +- `dmenu.foreground`: normal foreground color
       +- `dmenu.backgroundSel`: selected background color
       +- `dmenu.foregroundSel`: selected foreground color
       +- `dmenu.backgroundOut`: output background color
       +- `dmenu.foregroundOut`: output foreground color
       +- `dmenu.topbar`: position of dmenu at top (1) or bottom (0)
       +- `dmenu.lines`: number of lines for vertical display
       +
       +Values set in Xresources override those in config.h. Command line
       +arguments take precedence over both.
       +
       +## Download
       +
       +- [dmenu-xresources-4.9.diff](./dmenu-xresources-4.9.diff) (2020/05/24)
       +- [dmenu-xresources-alt-5.0.diff](./dmenu-xresources-alt-5.0.diff) (2021/04/15)
       +- [dmenu-xresources-20260510-7175c48.diff](./dmenu-xresources-20260510-7175c48.diff)
       +
       +## Authors
       +
       +- Michał Lemke - @melek on [Bitbucket](https://bitbucket.org/melek/dmenu2/)
       +- Pratik Bhusal (4.9 port)
       +- Nihal Jere <nihal@nihaljere.xyz> (20200302)
       +- Francesco Minnocci <ad17fmin@uwcad.it> (command line parameters fix)
       +- Vadim Zyamalov (alt-5.0)
       +- Justinas Grigas <dev@jstnas.com> (20260510)