summary refs log tree commit diff
path: root/xutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'xutil.c')
-rw-r--r--xutil.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/xutil.c b/xutil.c
index 7246531..e5129b6 100644
--- a/xutil.c
+++ b/xutil.c
@@ -184,3 +184,23 @@ xu_getatoms(void)
 {
 	XInternAtoms(X_Dpy, atoms, CWM_NO_ATOMS, False, cwm_atoms);
 }
+
+unsigned long
+xu_getcolor(struct screen_ctx *sc, char *name)
+{
+	XColor	 color, tmp;
+
+	if (!XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, sc->which),
+	    name, &color, &tmp)) {
+		warnx("XAllocNamedColor error: '%s'", name);
+		return 0;
+	}
+
+	return color.pixel;
+}
+
+void
+xu_freecolor(struct screen_ctx *sc, unsigned long pixel)
+{
+	XFreeColors(X_Dpy, DefaultColormap(X_Dpy, sc->which), &pixel, 1, 0L);
+}