commit 0b3cb33bf777f6c3044fc2a15b05628cefd8dc96
Author: nihal_AT_nihaljere.xyz <Nihal Jere>
Date: Mon Mar 2 16:38:47 2020 -0600
[dmenu][patch] xresources: fixed patch, updated description
diff --git a/tools.suckless.org/dmenu/patches/xresources/dmenu-xresources-20200302-db6093f.diff b/tools.suckless.org/dmenu/patches/xresources/dmenu-xresources-20200302-db6093f.diff
new file mode 100644
index 00000000..94304b97
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/xresources/dmenu-xresources-20200302-db6093f.diff
_AT_@ -0,0 +1,96 @@
+From 916c4921c4e870f77d91d816272375f90dc49867 Mon Sep 17 00:00:00 2001
+From: Nihal Jere <nihal_AT_nihaljere.xyz>
+Date: Mon, 2 Mar 2020 15:56:12 -0600
+Subject: [PATCH] xresources patch frees memory properly and no longer
+ segfaults
+
+---
+ dmenu.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++---
+ 1 file changed, 47 insertions(+), 3 deletions(-)
+
+diff --git a/dmenu.c b/dmenu.c
+index 65f25ce..d444e8c 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_@ -601,8 +602,13 @@ setup(void)
+ int a, di, n, area = 0;
+ #endif
+ /* init appearance */
+- for (j = 0; j < SchemeLast; j++)
+- scheme[j] = drw_scm_create(drw, colors[j], 2);
++ for (j = 0; j < SchemeLast; j++) {
++ scheme[j] = drw_scm_create(drw, (const char**)colors[j], 2);
++ }
++ for (j = 0; j < SchemeOut; ++j) {
++ for (i = 0; i < 2; ++i)
++ free(colors[j][i]);
++ }
+
+ clip = XInternAtom(dpy, "CLIPBOARD", False);
+ utf8 = XInternAtom(dpy, "UTF8_STRING", False);
+_AT_@ -694,6 +700,41 @@ usage(void)
+ exit(1);
+ }
+
++void
++readxresources(void) {
++ XrmInitialize();
++
++ char* xrm;
++ if ((xrm = XResourceManagerString(drw->dpy))) {
++ char *type;
++ XrmDatabase xdb = XrmGetStringDatabase(xrm);
++ XrmValue xval;
++
++ if (XrmGetResource(xdb, "dmenu.font", "*", &type, &xval))
++ fonts[0] = strdup(xval.addr);
++ else
++ fonts[0] = strdup(fonts[0]);
++ if (XrmGetResource(xdb, "dmenu.background", "*", &type, &xval))
++ colors[SchemeNorm][ColBg] = strdup(xval.addr);
++ else
++ colors[SchemeNorm][ColBg] = strdup(colors[SchemeNorm][ColBg]);
++ if (XrmGetResource(xdb, "dmenu.foreground", "*", &type, &xval))
++ colors[SchemeNorm][ColFg] = strdup(xval.addr);
++ else
++ colors[SchemeNorm][ColFg] = strdup(colors[SchemeNorm][ColFg]);
++ if (XrmGetResource(xdb, "dmenu.selbackground", "*", &type, &xval))
++ colors[SchemeSel][ColBg] = strdup(xval.addr);
++ else
++ colors[SchemeSel][ColBg] = strdup(colors[SchemeSel][ColBg]);
++ if (XrmGetResource(xdb, "dmenu.selforeground", "*", &type, &xval))
++ colors[SchemeSel][ColFg] = strdup(xval.addr);
++ else
++ colors[SchemeSel][ColFg] = strdup(colors[SchemeSel][ColFg]);
++
++ XrmDestroyDatabase(xdb);
++ }
++}
++
+ int
+ main(int argc, char *argv[])
+ {
+_AT_@ -748,8 +789,11 @@ 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);
+- if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
++ readxresources();
++ if (!drw_fontset_create(drw, (const char**)fonts, LENGTH(fonts)))
+ die("no fonts could be loaded.");
++
++ free(fonts[0]);
+ lrpad = drw->fonts->h;
+
+ #ifdef __OpenBSD__
+--
+2.25.1
+
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
deleted file mode 100644
index 943fdc68..00000000
--- a/tools.suckless.org/dmenu/patches/xresources/dmenu-xresources-4.9.diff
+++ /dev/null
_AT_@ -1,82 +0,0 @@
-From 5bd3be185cb9730ff49b72dc60dc8c18ae231ae3 Mon Sep 17 00:00:00 2001
-From: PratikBhusal <PratikBhusal_AT_users.noreply.github.com>
-Date: Fri, 20 Dec 2019 13:51:17 -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
-
-Note: Just like how it is in config.h, this patch only changes the
-default font and colors. If you wish to explicitly change the values via
-command line arguements, see "man dmenu" for more details.
----
- dmenu.c | 27 +++++++++++++++++++++++++++
- 1 file changed, 27 insertions(+)
-
-diff --git a/dmenu.c b/dmenu.c
-index 6b8f51b..8606dee 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,12 +688,38 @@ 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[])
- {
- XWindowAttributes wa;
- int i, fast = 0;
-
-+ read_Xresources();
- for (i = 1; i < argc; i++)
- /* these options take no arguments */
- if (!strcmp(argv[i], "-v")) { /* prints version information */
---
-2.24.1
-
diff --git a/tools.suckless.org/dmenu/patches/xresources/index.md b/tools.suckless.org/dmenu/patches/xresources/index.md
index 87bd1842..21b8634f 100644
--- a/tools.suckless.org/dmenu/patches/xresources/index.md
+++ b/tools.suckless.org/dmenu/patches/xresources/index.md
_AT_@ -3,12 +3,12 @@ xresources
Description
-----------
-This patch was origionally made by Michał Lemke has been slightly modified to
+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 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:
+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
_AT_@ -16,15 +16,15 @@ that can be changed and what they change:
- dmenu.selbackground : selected background color
- dmenu.selforeground : selected foreground color
-Note: Just like how it is in config.h, this patch only changes the default font
-and colors. If you wish to explicitly change the values via
-command line arguements, see "man dmenu" for more details.
+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)
+* [dmenu-xresources-20200302-db6093f.diff](dmenu-xresources-20200302-db6093f.diff)
Authors
-------
* Michał Lemke - _AT_melek on [Bitbucket](https://bitbucket.org/melek/dmenu2/)
* Pratik Bhusal - dmenu-xresources-4.9 port
+* Nihal Jere <nihal_AT_nihaljere.xyz> (20200302)
Received on Mon Mar 02 2020 - 23:39:18 CET