diff options
Diffstat (limited to 'modules/xrdb')
| -rw-r--r-- | modules/xrdb/xrdb.c | 42 | ||||
| -rw-r--r-- | modules/xrdb/xrdb.h | 20 |
2 files changed, 62 insertions, 0 deletions
diff --git a/modules/xrdb/xrdb.c b/modules/xrdb/xrdb.c new file mode 100644 index 0000000..556c6b8 --- /dev/null +++ b/modules/xrdb/xrdb.c @@ -0,0 +1,42 @@ +void +loadxrdb() +{ + Display *display; + char * resm; + XrmDatabase xrdb; + char *type; + XrmValue value; + + display = XOpenDisplay(NULL); + + if (display != NULL) { + resm = XResourceManagerString(display); + + if (resm != NULL) { + xrdb = XrmGetStringDatabase(resm); + + if (xrdb != NULL) { + XRDB_LOAD_COLOR("dwm.color0", normbordercolor); + XRDB_LOAD_COLOR("dwm.color8", selbordercolor); + XRDB_LOAD_COLOR("dwm.color0", normbgcolor); + XRDB_LOAD_COLOR("dwm.color6", normfgcolor); + XRDB_LOAD_COLOR("dwm.color0", selfgcolor); + XRDB_LOAD_COLOR("dwm.color14", selbgcolor); + } + } + } + + XCloseDisplay(display); +} + +void +xrdb(const Arg *arg) +{ + loadxrdb(); + int i; + for (i = 0; i < LENGTH(colors); i++) + scheme[i] = drw_scm_create(drw, colors[i], 3); + focus(NULL); + arrange(NULL); +} + diff --git a/modules/xrdb/xrdb.h b/modules/xrdb/xrdb.h new file mode 100644 index 0000000..aa7006f --- /dev/null +++ b/modules/xrdb/xrdb.h @@ -0,0 +1,20 @@ +#include <X11/Xresource.h> + +#define XRDB_LOAD_COLOR(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \ + if (value.addr != NULL && strnlen(value.addr, 8) == 7 && value.addr[0] == '#') { \ + int i = 1; \ + for (; i <= 6; i++) { \ + if (value.addr[i] < 48) break; \ + if (value.addr[i] > 57 && value.addr[i] < 65) break; \ + if (value.addr[i] > 70 && value.addr[i] < 97) break; \ + if (value.addr[i] > 102) break; \ + } \ + if (i == 7) { \ + strncpy(V, value.addr, 7); \ + V[7] = '\0'; \ + } \ + } \ + } + +static void loadxrdb(void); +static void xrdb(const Arg *arg); |
