aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dmenu.h3
-rw-r--r--draw.c5
-rw-r--r--main.c8
3 files changed, 9 insertions, 7 deletions
diff --git a/dmenu.h b/dmenu.h
index d4065d2..b58a32b 100644
--- a/dmenu.h
+++ b/dmenu.h
@@ -43,7 +43,8 @@ extern DC dc; /* global drawing context */
43/* draw.c */ 43/* draw.c */
44extern void drawtext(const char *text, 44extern void drawtext(const char *text,
45 unsigned long col[ColLast]); /* draws text with the defined color tuple */ 45 unsigned long col[ColLast]); /* draws text with the defined color tuple */
46extern unsigned long getcolor(const char *colstr); /* returns color of colstr */ 46extern unsigned long getcolor(
47 const char *colstr, const char *alternate); /* returns color of colstr */
47extern void setfont(const char *fontstr); /* sets global font */ 48extern void setfont(const char *fontstr); /* sets global font */
48extern unsigned int textw(const char *text); /* returns width of text in px */ 49extern unsigned int textw(const char *text); /* returns width of text in px */
49 50
diff --git a/draw.c b/draw.c
index 10a011d..dafc107 100644
--- a/draw.c
+++ b/draw.c
@@ -76,11 +76,12 @@ drawtext(const char *text, unsigned long col[ColLast]) {
76} 76}
77 77
78unsigned long 78unsigned long
79getcolor(const char *colstr) { 79getcolor(const char *colstr, const char *alternate) {
80 Colormap cmap = DefaultColormap(dpy, screen); 80 Colormap cmap = DefaultColormap(dpy, screen);
81 XColor color; 81 XColor color;
82 82
83 XAllocNamedColor(dpy, cmap, colstr, &color, &color); 83 if(XAllocNamedColor(dpy, cmap, colstr, &color, &color) != Success)
84 XAllocNamedColor(dpy, cmap, alternate, &color, &color);
84 return color.pixel; 85 return color.pixel;
85} 86}
86 87
diff --git a/main.c b/main.c
index 27b28af..5a9b3b9 100644
--- a/main.c
+++ b/main.c
@@ -341,10 +341,10 @@ main(int argc, char *argv[]) {
341 maxname = readstdin(); 341 maxname = readstdin();
342 342
343 /* style */ 343 /* style */
344 dc.sel[ColBG] = getcolor(selbg); 344 dc.norm[ColBG] = getcolor(normbg, NORMBGCOLOR);
345 dc.sel[ColFG] = getcolor(selfg); 345 dc.norm[ColFG] = getcolor(normfg, NORMFGCOLOR);
346 dc.norm[ColBG] = getcolor(normbg); 346 dc.sel[ColBG] = getcolor(selbg, SELBGCOLOR);
347 dc.norm[ColFG] = getcolor(normfg); 347 dc.sel[ColFG] = getcolor(selfg, SELFGCOLOR);
348 setfont(font); 348 setfont(font);
349 349
350 wa.override_redirect = 1; 350 wa.override_redirect = 1;