[wiki] [sites] Add failcolor patch to slock || Michael Stummvoll

From: <git_AT_suckless.org>
Date: Wed, 01 Jan 2014 16:15:14 +0100

commit 390cb399c52bfea3f57f00e8e028741ab1b68c02
Author: Michael Stummvoll <michael_AT_stummi.org>
Date: Wed Jan 1 16:13:40 2014 +0100

    Add failcolor patch to slock

diff --git a/tools.suckless.org/slock.md b/tools.suckless.org/slock.md
deleted file mode 100644
index 20172b5..0000000
--- a/tools.suckless.org/slock.md
+++ /dev/null
_AT_@ -1,30 +0,0 @@
-slock
-=====
-Simple X display locker. This is the simplest X screen locker we are
-aware of. It is stable and quite a lot of people in our community are using it
-every day when they are out with friends or fetching some food from the local
-pub.
-
-Development
------------
-You can [browse](http://git.suckless.org/slock) its source code repository
-or get a copy using the following command:
-
- git clone http://git.suckless.org/slock
-
-Download
---------
-* [slock-1.1](http://dl.suckless.org/tools/slock-1.1.tar.gz) (20121025)
-
-Xautolock
----------
-Slock can be started after a specific period of user inactivity using
-[xautolock](http://www.ibiblio.org/pub/linux/X11/screensavers/). The
-command syntax is:
-
- xautolock -time 10 -locker slock
-
-Simpler alternatives to xautolock might be
-[xssstate](http://git.suckless.org/xssstate/) or
-[xss](http://woozle.org/~neale/src/xss.html).
-
diff --git a/tools.suckless.org/slock/index.md b/tools.suckless.org/slock/index.md
new file mode 100644
index 0000000..20172b5
--- /dev/null
+++ b/tools.suckless.org/slock/index.md
_AT_@ -0,0 +1,30 @@
+slock
+=====
+Simple X display locker. This is the simplest X screen locker we are
+aware of. It is stable and quite a lot of people in our community are using it
+every day when they are out with friends or fetching some food from the local
+pub.
+
+Development
+-----------
+You can [browse](http://git.suckless.org/slock) its source code repository
+or get a copy using the following command:
+
+ git clone http://git.suckless.org/slock
+
+Download
+--------
+* [slock-1.1](http://dl.suckless.org/tools/slock-1.1.tar.gz) (20121025)
+
+Xautolock
+---------
+Slock can be started after a specific period of user inactivity using
+[xautolock](http://www.ibiblio.org/pub/linux/X11/screensavers/). The
+command syntax is:
+
+ xautolock -time 10 -locker slock
+
+Simpler alternatives to xautolock might be
+[xssstate](http://git.suckless.org/xssstate/) or
+[xss](http://woozle.org/~neale/src/xss.html).
+
diff --git a/tools.suckless.org/slock/patches/failcolor.md b/tools.suckless.org/slock/patches/failcolor.md
new file mode 100644
index 0000000..4419fa4
--- /dev/null
+++ b/tools.suckless.org/slock/patches/failcolor.md
_AT_@ -0,0 +1,17 @@
+Failcolor
+=========
+
+Description
+-----------
+
+Introduces an additional color to indicate an failed login attempt.
+
+Download
+--------
+
+* [slock-1.1-failcolor.diff](slock-1.1-failcolor.diff)
+
+Author
+------
+
+* Michael Stummvoll <[michael_AT_stummi.org](mailto:michael_AT_stummi.org)>
diff --git a/tools.suckless.org/slock/patches/slock-1.1-failcolor.diff b/tools.suckless.org/slock/patches/slock-1.1-failcolor.diff
new file mode 100644
index 0000000..8d0bf70
--- /dev/null
+++ b/tools.suckless.org/slock/patches/slock-1.1-failcolor.diff
_AT_@ -0,0 +1,67 @@
+diff --git a/config.mk b/config.mk
+index 8cc3f68..016a851 100644
+--- a/config.mk
++++ b/config.mk
+_AT_@ -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=\"\#550000\"
+ CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
+ LDFLAGS = -s ${LIBS}
+
+diff --git a/slock.c b/slock.c
+index 467937c..32f5d96 100644
+--- a/slock.c
++++ b/slock.c
+_AT_@ -27,12 +27,13 @@ typedef struct {
+ int screen;
+ Window root, win;
+ Pixmap pmap;
+- unsigned long colors[2];
++ unsigned long colors[3];
+ } Lock;
+
+ static Lock **locks;
+ static int nscreens;
+ static Bool running = True;
++static Bool tried = False;
+
+ static void
+ die(const char *errstr, ...) {
+_AT_@ -130,6 +131,7 @@ readpw(Display *dpy, const char *pws)
+ #ifdef HAVE_BSD_AUTH
+ running = !auth_userokay(getlogin(), NULL, "auth-xlock", passwd);
+ #else
++ tried=True;
+ running = !!strcmp(crypt(passwd, pws), pws);
+ #endif
+ if(running)
+_AT_@ -157,7 +159,7 @@ readpw(Display *dpy, const char *pws)
+ }
+ } else if(llen != 0 && len == 0) {
+ for(screen = 0; screen < nscreens; screen++) {
+- XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[0]);
++ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[tried ? 2 : 0]);
+ XClearWindow(dpy, locks[screen]->win);
+ }
+ }
+_AT_@ -174,7 +176,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);
+
+_AT_@ -207,6 +209,8 @@ lockscreen(Display *dpy, int screen) {
+ 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);
++ XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR3, &color, &dummy);
++ lock->colors[2] = color.pixel;
+ XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR2, &color, &dummy);
+ lock->colors[1] = color.pixel;
+ XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR1, &color, &dummy);
Received on Wed Jan 01 2014 - 16:15:14 CET

This archive was generated by hypermail 2.3.0 : Thu Jun 18 2015 - 17:38:03 CEST