diff options
-rw-r--r-- | README | 12 | ||||
-rw-r--r-- | README.dzen | 12 | ||||
-rw-r--r-- | dzen.h | 1 | ||||
-rw-r--r-- | main.c | 38 |
4 files changed, 58 insertions, 5 deletions
@@ -97,6 +97,18 @@ dzen accepts a couple of options: +X resources +----------- + +Dzen is able to read font and color setting from X resources. +As an example you can add following lines to ~/.Xresources + +dzen2.font: -*-fixed-*-*-*-*-*-*-*-*-*-*-*-* +dzen2.foreground: #22EE11 +dzen2.background: black + + + Window layout ------------- diff --git a/README.dzen b/README.dzen index 9332164..43f9a50 100644 --- a/README.dzen +++ b/README.dzen @@ -97,6 +97,18 @@ dzen accepts a couple of options: +^fg(#6fbf47)X resources +^fg(#6fbf47)----------- + +Dzen is able to read font and color setting from X resources. +As an example you can add following lines to ~/.Xresources + +^fg(Khaki)dzen2.font: -*-fixed-*-*-*-*-*-*-*-*-*-*-*-* +^fg(Khaki)dzen2.foreground: #22EE11 +^fg(Khaki)dzen2.background: black + + + ^fg(#6fbf47)Window layout ^fg(#6fbf47)------------- @@ -6,6 +6,7 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> +#include <X11/Xresource.h> #ifdef DZEN_XINERAMA #include <X11/extensions/Xinerama.h> #endif @@ -385,17 +385,41 @@ x_create_gcs(void) { } static void +x_connect(void) { + dzen.dpy = XOpenDisplay(0); + if(!dzen.dpy) + eprint("dzen: cannot open display\n"); + dzen.screen = DefaultScreen(dzen.dpy); +} + +/* Read display styles from X resources. */ +static void +x_read_resources(void) { + XrmDatabase xdb; + char* xrm; + char* datatype[20]; + XrmValue xvalue; + + xrm = XResourceManagerString(dzen.dpy); + if( xrm != NULL ) { + xdb = XrmGetStringDatabase(xrm); + if( XrmGetResource(xdb, "dzen2.font", "*", datatype, &xvalue) == True ) + dzen.fnt = estrdup(xvalue.addr); + if( XrmGetResource(xdb, "dzen2.foreground", "*", datatype, &xvalue) == True ) + dzen.fg = estrdup(xvalue.addr); + if( XrmGetResource(xdb, "dzen2.background", "*", datatype, &xvalue) == True ) + dzen.bg = estrdup(xvalue.addr); + XrmDestroyDatabase(xdb); + } +} + +static void x_create_windows(int use_ewmh_dock) { XSetWindowAttributes wa; Window root; int i; XRectangle si; - dzen.dpy = XOpenDisplay(0); - if(!dzen.dpy) - eprint("dzen: cannot open display\n"); - - dzen.screen = DefaultScreen(dzen.dpy); root = RootWindow(dzen.dpy, dzen.screen); /* style */ @@ -797,6 +821,10 @@ main(int argc, char *argv[]) { dzen.line_height = 0; dzen.title_win.expand = noexpand; + /* Connect to X server */ + x_connect(); + x_read_resources(); + /* cmdline args */ for(i = 1; i < argc; i++) if(!strncmp(argv[i], "-l", 3)){ |