sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 5248769921d93a6c3cfd126356a5bd1a81b816e7
parent 5b2da61008c66866a97b71ae21b7cacff9e0d737
Author: Alexey Khudyakov <alexey.skladnoy@gmail.com>
Date:   Thu, 16 Dec 2010 23:51:23 +0300

Patch for readgin settings from X resource database
Diffstat:
Atools.suckless.org/dmenu/patches/xrdb.diff | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools.suckless.org/dmenu/patches/xrdb.md | 16++++++++++++++++
2 files changed, 101 insertions(+), 0 deletions(-)

diff --git a/tools.suckless.org/dmenu/patches/xrdb.diff b/tools.suckless.org/dmenu/patches/xrdb.diff @@ -0,0 +1,85 @@ +diff -r 2b9683c50723 -r ebcc0d8213e0 dmenu.c +--- a/dmenu.c Wed Dec 01 20:25:10 2010 +0000 ++++ b/dmenu.c Tue Dec 14 15:53:44 2010 +0300 +@@ -7,6 +7,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 +@@ -37,6 +38,7 @@ + static void run(void); + static void setup(void); + static void usage(void); ++static void read_resourses(void); + + static char text[BUFSIZ]; + static int bh, mw, mh; +@@ -47,10 +49,10 @@ + static size_t cursor = 0; + static const char *font = NULL; + static const char *prompt = NULL; +-static const char *normbgcolor = "#cccccc"; +-static const char *normfgcolor = "#000000"; +-static const char *selbgcolor = "#0066ff"; +-static const char *selfgcolor = "#ffffff"; ++static const char *normbgcolor = NULL; ++static const char *normfgcolor = NULL; ++static const char *selbgcolor = NULL; ++static const char *selfgcolor = NULL; + static unsigned long normcol[ColLast]; + static unsigned long selcol[ColLast]; + static Atom utf8; +@@ -101,6 +103,7 @@ + usage(); + + dc = initdc(); ++ read_resourses(); + initfont(dc, font); + readstdin(); + setup(); +@@ -109,6 +112,42 @@ + return EXIT_FAILURE; /* should not reach */ + } + ++/* Set font and colors from X resources database if they are not set ++ * from command line */ ++void ++read_resourses(void) { ++ XrmDatabase xdb; ++ char* xrm; ++ char* datatype[20]; ++ XrmValue xvalue; ++ ++ XrmInitialize(); ++ xrm = XResourceManagerString(dc->dpy); ++ if( xrm != NULL ) { ++ xdb = XrmGetStringDatabase(xrm); ++ if( font == NULL && XrmGetResource(xdb, "dmenu.font", "*", datatype, &xvalue) == True ) ++ font = strdup(xvalue.addr); ++ if( normfgcolor == NULL && XrmGetResource(xdb, "dmenu.foreground", "*", datatype, &xvalue) == True ) ++ normfgcolor = strdup(xvalue.addr); ++ if( normbgcolor == NULL && XrmGetResource(xdb, "dmenu.background", "*", datatype, &xvalue) == True ) ++ normbgcolor = strdup(xvalue.addr); ++ if( selfgcolor == NULL && XrmGetResource(xdb, "dmenu.selforeground", "*", datatype, &xvalue) == True ) ++ selfgcolor = strdup(xvalue.addr); ++ if( selbgcolor == NULL && XrmGetResource(xdb, "dmenu.selbackground", "*", datatype, &xvalue) == True ) ++ selbgcolor = strdup(xvalue.addr); ++ XrmDestroyDatabase(xdb); ++ } ++ /* Set default colors if they are not set */ ++ if( normbgcolor == NULL ) ++ normbgcolor = "#cccccc"; ++ if( normfgcolor == NULL ) ++ normfgcolor = "#000000"; ++ if( selbgcolor == NULL ) ++ selbgcolor = "#0066ff"; ++ if( selfgcolor == NULL ) ++ selfgcolor = "#ffffff"; ++} ++ + void + appenditem(Item *item, Item **list, Item **last) { + if(!*last) diff --git a/tools.suckless.org/dmenu/patches/xrdb.md b/tools.suckless.org/dmenu/patches/xrdb.md @@ -0,0 +1,16 @@ +INCREMENTAL OUTPUT +================== + +This patch allows to confgure font and colors using X resource database. +Following resources are supported: + + * dmenu.font - font + * dmenu.foreground - foreground color + * dmenu.background - background color + * dmenu.selforeground - foreground color for selected area + * dmenu.selbackground - background color for selected area + +Download +-------- + +* [xrdb.diff](xrdb.diff)