sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 58fa96d8551dc2de2ff44e650e2b9a65b264bd8b
parent 33b3bf5a197c9663b6041b54ebcbb49dd76d69fa
Author: Andrew Hills <ahills@ednos.net>
Date:   Sun,  1 Mar 2015 12:48:16 -0500

Added slock patch for Caps Lock color indicator

Diffstat:
Atools.suckless.org/slock/patches/capscolor.md | 19+++++++++++++++++++
Atools.suckless.org/slock/patches/slock-capscolor.diff | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 117 insertions(+), 0 deletions(-)

diff --git a/tools.suckless.org/slock/patches/capscolor.md b/tools.suckless.org/slock/patches/capscolor.md @@ -0,0 +1,19 @@ +Capscolor +========= + +Description +----------- + +Introduces an additional color to indicate the state of Caps Lock. Not +compatible with the [failcolor](./failcolor) patch. Written against HEAD at +a31b919, but should apply to 1.2. + +Download +-------- + +* [slock-capscolor.diff](slock-capscolor.diff) + +Author +------ + +* Andrew Hills <[ahills@ednos.net](mailto:ahills@ednos.net)> diff --git a/tools.suckless.org/slock/patches/slock-capscolor.diff b/tools.suckless.org/slock/patches/slock-capscolor.diff @@ -0,0 +1,98 @@ +diff --git a/config.def.h b/config.def.h +index 89e5977..27d533f 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -1,2 +1,3 @@ + #define COLOR1 "black" + #define COLOR2 "#005577" ++#define COLORC "red" +diff --git a/slock.c b/slock.c +index 407a540..77bfc1f 100644 +--- a/slock.c ++++ b/slock.c +@@ -16,6 +16,7 @@ + #include <X11/keysym.h> + #include <X11/Xlib.h> + #include <X11/Xutil.h> ++#include <X11/XKBlib.h> + + #if HAVE_BSD_AUTH + #include <login_cap.h> +@@ -28,7 +29,7 @@ typedef struct { + int screen; + Window root, win; + Pixmap pmap; +- unsigned long colors[2]; ++ unsigned long colors[3]; + } Lock; + + static Lock **locks; +@@ -106,14 +107,18 @@ readpw(Display *dpy, const char *pws) + #endif + { + char buf[32], passwd[256]; +- int num, screen; +- unsigned int len, llen; ++ int num, screen, caps, lcaps; ++ unsigned int len, llen, indicators; + KeySym ksym; + XEvent ev; + + len = llen = 0; ++ caps = lcaps = 0; + running = True; + ++ if(!XkbGetIndicatorState(dpy, XkbUseCoreKbd, &indicators)) ++ caps = indicators & 1; ++ + /* As "slock" stands for "Simple X display locker", the DPMS settings + * had been removed and you can set it with "xset" or some other + * utility. This way the user can easily set a customized DPMS +@@ -153,6 +158,9 @@ readpw(Display *dpy, const char *pws) + if (len) + --len; + break; ++ case XK_Caps_Lock: ++ caps = !caps; ++ break; + default: + if (num && !iscntrl((int) buf[0]) && (len + num < sizeof passwd)) { + memcpy(passwd + len, buf, num); +@@ -160,9 +168,9 @@ readpw(Display *dpy, const char *pws) + } + break; + } +- if (llen == 0 && len != 0) { ++ if ((llen == 0 && len != 0) || caps != lcaps) { + for (screen = 0; screen < nscreens; screen++) { +- XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[1]); ++ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[caps ? 2 : 1]); + XClearWindow(dpy, locks[screen]->win); + } + } else if (llen != 0 && len == 0) { +@@ -172,6 +180,7 @@ readpw(Display *dpy, const char *pws) + } + } + llen = len; ++ lcaps = caps; + } + else for (screen = 0; screen < nscreens; screen++) + XRaiseWindow(dpy, locks[screen]->win); +@@ -185,7 +194,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); + +@@ -219,6 +228,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), COLORC, &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);