[wiki] [sites] [dmenu][patch][xresources] Enabled default font & color change || PratikBhusal

From: <git_AT_suckless.org>
Date: Sun, 15 Dec 2019 03:19:56 +0100

commit a307de51f0fb74d205b7acedd5d84dc6fb0a5f52
Author: PratikBhusal <PratikBhusal_AT_users.noreply.github.com>
Date: Sat Dec 14 20:18:20 2019 -0600

    [dmenu][patch][xresources] Enabled default font & color change

diff --git a/tools.suckless.org/dmenu/patches/xresources/dmenu-xresources-4.9.diff b/tools.suckless.org/dmenu/patches/xresources/dmenu-xresources-4.9.diff
new file mode 100644
index 00000000..4090a380
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/xresources/dmenu-xresources-4.9.diff
_AT_@ -0,0 +1,79 @@
+From ed9359221c52f239d887b6ee4de152428316dd73 Mon Sep 17 00:00:00 2001
+From: PratikBhusal <PratikBhusal_AT_users.noreply.github.com>
+Date: Sat, 14 Dec 2019 19:53:28 -0600
+Subject: [PATCH] Extract Xresources patch by _AT_melek to dmenu
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This patch was origionally made by Michał Lemke has been slightly
+modified to work with dmenu 4.9.
+
+This patch adds the ability to configure st via Xresources. At startup,
+st 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
+---
+ dmenu.c | 27 +++++++++++++++++++++++++++
+ 1 file changed, 27 insertions(+)
+
+diff --git a/dmenu.c b/dmenu.c
+index 6b8f51b..3373abe 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -15,6 +15,7 @@
+ #include <X11/extensions/Xinerama.h>
+ #endif
+ #include <X11/Xft/Xft.h>
++#include <X11/Xresource.h>
+
+ #include "drw.h"
+ #include "util.h"
+_AT_@ -687,6 +688,31 @@ usage(void)
+ exit(1);
+ }
+
++void
++read_Xresources(void) {
++ XrmInitialize();
++
++ char* xrm;
++ if ((xrm = XResourceManagerString(drw->dpy))) {
++ char *type;
++ XrmDatabase xdb = XrmGetStringDatabase(xrm);
++ XrmValue xval;
++
++ if (XrmGetResource(xdb, "dmenu.font", "*", &type, &xval) == True) /* font or font set */
++ fonts[0] = strdup(xval.addr);
++ if (XrmGetResource(xdb, "dmenu.background", "*", &type, &xval) == True) /* normal background color */
++ colors[SchemeSel][ColBg] = strdup(xval.addr);
++ if (XrmGetResource(xdb, "dmenu.foreground", "*", &type, &xval) == True) /* normal foreground color */
++ colors[SchemeNorm][ColFg] = strdup(xval.addr);
++ if (XrmGetResource(xdb, "dmenu.selbackground", "*", &type, &xval) == True) /* selected background color */
++ colors[SchemeSel][ColBg] = strdup(xval.addr);
++ if (XrmGetResource(xdb, "dmenu.selforeground", "*", &type, &xval) == True) /* selected foreground color */
++ colors[SchemeSel][ColFg] = strdup(xval.addr);
++
++ XrmDestroyDatabase(xdb);
++ }
++}
++
+ int
+ main(int argc, char *argv[])
+ {
+_AT_@ -743,6 +769,7 @@ main(int argc, char *argv[])
+ die("could not get embedding window attributes: 0x%lx",
+ parentwin);
+ drw = drw_create(dpy, screen, root, wa.width, wa.height);
++ read_Xresources();
+ if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
+ die("no fonts could be loaded.");
+ lrpad = drw->fonts->h;
+--
+2.24.1
+
diff --git a/tools.suckless.org/dmenu/patches/xresources/index.md b/tools.suckless.org/dmenu/patches/xresources/index.md
new file mode 100644
index 00000000..eface9d5
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/xresources/index.md
_AT_@ -0,0 +1,26 @@
+xresources
+==========
+
+Description
+-----------
+This patch was origionally made by Michał Lemke has been slightly modified to
+work with dmenu 4.9.
+
+This patch adds the ability to configure st via Xresources. At startup, st 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
+
+Download
+--------
+* [dmenu-xresources-4.9.diff](dmenu-xresources-4.9.diff)
+
+Authors
+-------
+* Michał Lemke - _AT_melek on [Bitbucket](https://bitbucket.org/melek/dmenu2/)
+* Pratik Bhusal - dmenu-xresources-4.9 port
Received on Sun Dec 15 2019 - 03:19:56 CET

This archive was generated by hypermail 2.3.0 : Sun Dec 15 2019 - 03:24:37 CET