diff options
author | alexey.skladnoy <alexey.skladnoy@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2008-07-22 14:05:26 +0000 |
---|---|---|
committer | alexey.skladnoy <alexey.skladnoy@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2008-07-22 14:05:26 +0000 |
commit | 58f511fe8d8df9d33018dd34d357f46ce9046d3e (patch) | |
tree | cfeb3d06e1c75d6c81be657804a7949633d451e6 | |
parent | 01d2dc398add06d90119c45e7d060de73f72d8f7 (diff) | |
download | dzen-58f511fe8d8df9d33018dd34d357f46ce9046d3e.tar.gz dzen-58f511fe8d8df9d33018dd34d357f46ce9046d3e.zip |
Dzen is now able to get font and color settings from X resources
- Order of initialization changed:
1. connect to X server
2. Read X resources
3. Parse command line options
- README files updated
- x_read_resources may contain bugs
git-svn-id: http://dzen.googlecode.com/svn/trunk@230 f2baff5b-bf2c-0410-a398-912abdc3d8b2
-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)){ |