Created
September 9, 2014 06:10
-
-
Save ryot4/94fc00858930850f62ac to your computer and use it in GitHub Desktop.
A patch which adds COLOR3 to slock (http://tools.suckless.org/slock/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/config.mk b/config.mk | |
index 8cc3f68..941e265 100644 | |
--- a/config.mk | |
+++ b/config.mk | |
@@ -14,7 +14,7 @@ INCS = -I. -I/usr/include -I${X11INC} | |
LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext | |
# flags | |
-CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H -DCOLOR1=\"black\" -DCOLOR2=\"\#005577\" | |
+CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H -DCOLOR1=\"black\" -DCOLOR2=\"\#005577\" -DCOLOR3=\"\#333333\" | |
CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} | |
LDFLAGS = -s ${LIBS} | |
diff --git a/slock.c b/slock.c | |
index 399386b..9af86b4 100644 | |
--- a/slock.c | |
+++ b/slock.c | |
@@ -27,7 +27,7 @@ typedef struct { | |
int screen; | |
Window root, win; | |
Pixmap pmap; | |
- unsigned long colors[2]; | |
+ unsigned long colors[3]; | |
} Lock; | |
static Lock **locks; | |
@@ -179,7 +179,7 @@ unlockscreen(Display *dpy, Lock *lock) { | |
return; | |
XUngrabPointer(dpy, CurrentTime); | |
- XFreeColors(dpy, DefaultColormap(dpy, lock->screen), lock->colors, 2, 0); | |
+ XFreeColors(dpy, DefaultColormap(dpy, lock->screen), lock->colors, 3, 0); | |
XFreePixmap(dpy, lock->pmap); | |
XDestroyWindow(dpy, lock->win); | |
@@ -208,7 +208,9 @@ lockscreen(Display *dpy, int screen) { | |
/* init */ | |
wa.override_redirect = 1; | |
- wa.background_pixel = BlackPixel(dpy, lock->screen); | |
+ XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR3, &color, &dummy); | |
+ lock->colors[3] = color.pixel; | |
+ wa.background_pixel = lock->colors[3]; | |
lock->win = XCreateWindow(dpy, lock->root, 0, 0, DisplayWidth(dpy, lock->screen), DisplayHeight(dpy, lock->screen), | |
0, DefaultDepth(dpy, lock->screen), CopyFromParent, | |
DefaultVisual(dpy, lock->screen), CWOverrideRedirect | CWBackPixel, &wa); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment