summaryrefslogtreecommitdiff
path: root/desktop/slock
diff options
context:
space:
mode:
authorRobby Workman <rworkman@slackbuilds.org>2016-01-09 23:13:52 -0600
committerRobby Workman <rworkman@slackbuilds.org>2016-01-10 21:36:31 -0600
commit65271fcf4d1c2cc28f4b5a440b553d5647dcd2e5 (patch)
tree92021468d6d9d2a3dd3f057982b0998ac532ac7c /desktop/slock
parentdb8440e2ba43a9c83c3c29543ccc5dad026c611c (diff)
downloadslackbuilds-65271fcf4d1c2cc28f4b5a440b553d5647dcd2e5.tar.gz
desktop/slock: Added some patches from upstream git
Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
Diffstat (limited to 'desktop/slock')
-rw-r--r--desktop/slock/patches/0001-applied-Dimitris-style-patch-from-Dec-14-with-some-m.patch316
-rw-r--r--desktop/slock/patches/0002-Blank-the-screen-with-color-0-add-third-color-for-fa.patch119
-rw-r--r--desktop/slock/patches/0003-resize-lockscreen-window-after-Xrandr-resize.patch83
-rw-r--r--desktop/slock/patches/0004-Option-to-not-show-failure-color-on-clear.patch64
-rw-r--r--desktop/slock/patches/0005-consistently-use-with-sizeof.patch34
-rw-r--r--desktop/slock/patches/0006-rework-setting-window-color.patch54
-rw-r--r--desktop/slock/patches/0007-Slightly-safer-OOM-killer-disablement-in-linux.patch45
-rw-r--r--desktop/slock/patches/0008-Don-t-change-to-failure-colour-on-success.patch25
-rw-r--r--desktop/slock/patches/0009-add-option-to-run-command-after-screen-is-locked.patch49
-rw-r--r--desktop/slock/patches/config.mk.patch (renamed from desktop/slock/config.mk.patch)0
-rw-r--r--desktop/slock/slock-1.2-failcolor.diff62
-rw-r--r--desktop/slock/slock.SlackBuild21
12 files changed, 802 insertions, 70 deletions
diff --git a/desktop/slock/patches/0001-applied-Dimitris-style-patch-from-Dec-14-with-some-m.patch b/desktop/slock/patches/0001-applied-Dimitris-style-patch-from-Dec-14-with-some-m.patch
new file mode 100644
index 0000000000..d92e14925b
--- /dev/null
+++ b/desktop/slock/patches/0001-applied-Dimitris-style-patch-from-Dec-14-with-some-m.patch
@@ -0,0 +1,316 @@
+From a31b9191111572dafaa8366415b89a4472aa4626 Mon Sep 17 00:00:00 2001
+From: Anselm R Garbe <garbeam@gmail.com>
+Date: Tue, 27 Jan 2015 22:16:52 +0100
+Subject: [PATCH 1/9] applied Dimitris' style patch from Dec'14, with some
+ minor modifications
+
+---
+ slock.c | 112 ++++++++++++++++++++++++++++++++++------------------------------
+ 1 file changed, 60 insertions(+), 52 deletions(-)
+
+diff --git a/slock.c b/slock.c
+index face75e..407a540 100644
+--- a/slock.c
++++ b/slock.c
+@@ -1,4 +1,3 @@
+-
+ /* See LICENSE file for license details. */
+ #define _XOPEN_SOURCE 500
+ #if HAVE_SHADOW_H
+@@ -37,20 +36,22 @@ static int nscreens;
+ static Bool running = True;
+
+ static void
+-die(const char *errstr, ...) {
++die(const char *errstr, ...)
++{
+ va_list ap;
+
+ va_start(ap, errstr);
+ vfprintf(stderr, errstr, ap);
+ va_end(ap);
+- exit(EXIT_FAILURE);
++ exit(1);
+ }
+
+ #ifdef __linux__
+ #include <fcntl.h>
+
+ static void
+-dontkillme(void) {
++dontkillme(void)
++{
+ int fd;
+
+ fd = open("/proc/self/oom_score_adj", O_WRONLY);
+@@ -62,8 +63,10 @@ dontkillme(void) {
+ #endif
+
+ #ifndef HAVE_BSD_AUTH
++/* only run as root */
+ static const char *
+-getpw(void) { /* only run as root */
++getpw(void)
++{
+ const char *rval;
+ struct passwd *pw;
+
+@@ -73,7 +76,7 @@ getpw(void) { /* only run as root */
+ if (errno)
+ die("slock: getpwuid: %s\n", strerror(errno));
+ else
+- die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
++ die("slock: cannot retrieve password entry\n");
+ }
+ rval = pw->pw_passwd;
+
+@@ -81,15 +84,15 @@ getpw(void) { /* only run as root */
+ if (rval[0] == 'x' && rval[1] == '\0') {
+ struct spwd *sp;
+ sp = getspnam(getenv("USER"));
+- if(!sp)
++ if (!sp)
+ die("slock: cannot retrieve shadow entry (make sure to suid or sgid slock)\n");
+ rval = sp->sp_pwdp;
+ }
+ #endif
+
+ /* drop privileges */
+- if (geteuid() == 0
+- && ((getegid() != pw->pw_gid && setgid(pw->pw_gid) < 0) || setuid(pw->pw_uid) < 0))
++ if (geteuid() == 0 &&
++ ((getegid() != pw->pw_gid && setgid(pw->pw_gid) < 0) || setuid(pw->pw_uid) < 0))
+ die("slock: cannot drop privileges\n");
+ return rval;
+ }
+@@ -115,21 +118,23 @@ readpw(Display *dpy, const char *pws)
+ * had been removed and you can set it with "xset" or some other
+ * utility. This way the user can easily set a customized DPMS
+ * timeout. */
+- while(running && !XNextEvent(dpy, &ev)) {
+- if(ev.type == KeyPress) {
++ while (running && !XNextEvent(dpy, &ev)) {
++ if (ev.type == KeyPress) {
+ buf[0] = 0;
+ num = XLookupString(&ev.xkey, buf, sizeof buf, &ksym, 0);
+- if(IsKeypadKey(ksym)) {
+- if(ksym == XK_KP_Enter)
++ if (IsKeypadKey(ksym)) {
++ if (ksym == XK_KP_Enter)
+ ksym = XK_Return;
+- else if(ksym >= XK_KP_0 && ksym <= XK_KP_9)
++ else if (ksym >= XK_KP_0 && ksym <= XK_KP_9)
+ ksym = (ksym - XK_KP_0) + XK_0;
+ }
+- if(IsFunctionKey(ksym) || IsKeypadKey(ksym)
+- || IsMiscFunctionKey(ksym) || IsPFKey(ksym)
+- || IsPrivateKeypadKey(ksym))
++ if (IsFunctionKey(ksym) ||
++ IsKeypadKey(ksym) ||
++ IsMiscFunctionKey(ksym) ||
++ IsPFKey(ksym) ||
++ IsPrivateKeypadKey(ksym))
+ continue;
+- switch(ksym) {
++ switch (ksym) {
+ case XK_Return:
+ passwd[len] = 0;
+ #ifdef HAVE_BSD_AUTH
+@@ -137,7 +142,7 @@ readpw(Display *dpy, const char *pws)
+ #else
+ running = !!strcmp(crypt(passwd, pws), pws);
+ #endif
+- if(running)
++ if (running)
+ XBell(dpy, 100);
+ len = 0;
+ break;
+@@ -145,36 +150,37 @@ readpw(Display *dpy, const char *pws)
+ len = 0;
+ break;
+ case XK_BackSpace:
+- if(len)
++ if (len)
+ --len;
+ break;
+ default:
+- if(num && !iscntrl((int) buf[0]) && (len + num < sizeof passwd)) {
++ if (num && !iscntrl((int) buf[0]) && (len + num < sizeof passwd)) {
+ memcpy(passwd + len, buf, num);
+ len += num;
+ }
+ break;
+ }
+- if(llen == 0 && len != 0) {
+- for(screen = 0; screen < nscreens; screen++) {
++ if (llen == 0 && len != 0) {
++ for (screen = 0; screen < nscreens; screen++) {
+ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[1]);
+ XClearWindow(dpy, locks[screen]->win);
+ }
+- } else if(llen != 0 && len == 0) {
+- for(screen = 0; screen < nscreens; screen++) {
++ } else if (llen != 0 && len == 0) {
++ for (screen = 0; screen < nscreens; screen++) {
+ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[0]);
+ XClearWindow(dpy, locks[screen]->win);
+ }
+ }
+ llen = len;
+ }
+- else for(screen = 0; screen < nscreens; screen++)
++ else for (screen = 0; screen < nscreens; screen++)
+ XRaiseWindow(dpy, locks[screen]->win);
+ }
+ }
+
+ static void
+-unlockscreen(Display *dpy, Lock *lock) {
++unlockscreen(Display *dpy, Lock *lock)
++{
+ if(dpy == NULL || lock == NULL)
+ return;
+
+@@ -187,7 +193,8 @@ unlockscreen(Display *dpy, Lock *lock) {
+ }
+
+ static Lock *
+-lockscreen(Display *dpy, int screen) {
++lockscreen(Display *dpy, int screen)
++{
+ char curs[] = {0, 0, 0, 0, 0, 0, 0, 0};
+ unsigned int len;
+ Lock *lock;
+@@ -195,11 +202,11 @@ lockscreen(Display *dpy, int screen) {
+ XSetWindowAttributes wa;
+ Cursor invisible;
+
+- if(dpy == NULL || screen < 0)
++ if (dpy == NULL || screen < 0)
+ return NULL;
+
+ lock = malloc(sizeof(Lock));
+- if(lock == NULL)
++ if (lock == NULL)
+ return NULL;
+
+ lock->screen = screen;
+@@ -210,8 +217,8 @@ lockscreen(Display *dpy, int screen) {
+ wa.override_redirect = 1;
+ wa.background_pixel = BlackPixel(dpy, lock->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);
++ 0, DefaultDepth(dpy, lock->screen), CopyFromParent,
++ DefaultVisual(dpy, lock->screen), CWOverrideRedirect | CWBackPixel, &wa);
+ XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR2, &color, &dummy);
+ lock->colors[1] = color.pixel;
+ XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR1, &color, &dummy);
+@@ -220,36 +227,37 @@ lockscreen(Display *dpy, int screen) {
+ invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &color, 0, 0);
+ XDefineCursor(dpy, lock->win, invisible);
+ XMapRaised(dpy, lock->win);
+- for(len = 1000; len; len--) {
+- if(XGrabPointer(dpy, lock->root, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
+- GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess)
++ for (len = 1000; len; len--) {
++ if (XGrabPointer(dpy, lock->root, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
++ GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess)
+ break;
+ usleep(1000);
+ }
+- if(running && (len > 0)) {
+- for(len = 1000; len; len--) {
+- if(XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
+- == GrabSuccess)
++ if (running && (len > 0)) {
++ for (len = 1000; len; len--) {
++ if (XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
+ break;
+ usleep(1000);
+ }
+ }
+
+ running &= (len > 0);
+- if(!running) {
++ if (!running) {
+ unlockscreen(dpy, lock);
+ lock = NULL;
+ }
+- else
++ else {
+ XSelectInput(dpy, lock->root, SubstructureNotifyMask);
++ }
+
+ return lock;
+ }
+
+ static void
+-usage(void) {
++usage(void)
++{
+ fprintf(stderr, "usage: slock [-v]\n");
+- exit(EXIT_FAILURE);
++ exit(1);
+ }
+
+ int
+@@ -260,38 +268,38 @@ main(int argc, char **argv) {
+ Display *dpy;
+ int screen;
+
+- if((argc == 2) && !strcmp("-v", argv[1]))
+- die("slock-%s, © 2006-2014 slock engineers\n", VERSION);
+- else if(argc != 1)
++ if ((argc == 2) && !strcmp("-v", argv[1]))
++ die("slock-%s, © 2006-2015 slock engineers\n", VERSION);
++ else if (argc != 1)
+ usage();
+
+ #ifdef __linux__
+ dontkillme();
+ #endif
+
+- if(!getpwuid(getuid()))
++ if (!getpwuid(getuid()))
+ die("slock: no passwd entry for you\n");
+
+ #ifndef HAVE_BSD_AUTH
+ pws = getpw();
+ #endif
+
+- if(!(dpy = XOpenDisplay(0)))
++ if (!(dpy = XOpenDisplay(0)))
+ die("slock: cannot open display\n");
+ /* Get the number of screens in display "dpy" and blank them all. */
+ nscreens = ScreenCount(dpy);
+ locks = malloc(sizeof(Lock *) * nscreens);
+- if(locks == NULL)
++ if (locks == NULL)
+ die("slock: malloc: %s\n", strerror(errno));
+ int nlocks = 0;
+- for(screen = 0; screen < nscreens; screen++) {
++ for (screen = 0; screen < nscreens; screen++) {
+ if ( (locks[screen] = lockscreen(dpy, screen)) != NULL)
+ nlocks++;
+ }
+ XSync(dpy, False);
+
+ /* Did we actually manage to lock something? */
+- if (nlocks == 0) { // nothing to protect
++ if (nlocks == 0) { /* nothing to protect */
+ free(locks);
+ XCloseDisplay(dpy);
+ return 1;
+@@ -305,7 +313,7 @@ main(int argc, char **argv) {
+ #endif
+
+ /* Password ok, unlock everything and quit. */
+- for(screen = 0; screen < nscreens; screen++)
++ for (screen = 0; screen < nscreens; screen++)
+ unlockscreen(dpy, locks[screen]);
+
+ free(locks);
+--
+2.6.4
+
diff --git a/desktop/slock/patches/0002-Blank-the-screen-with-color-0-add-third-color-for-fa.patch b/desktop/slock/patches/0002-Blank-the-screen-with-color-0-add-third-color-for-fa.patch
new file mode 100644
index 0000000000..14d649f942
--- /dev/null
+++ b/desktop/slock/patches/0002-Blank-the-screen-with-color-0-add-third-color-for-fa.patch
@@ -0,0 +1,119 @@
+From f2ea92c3ddf1d9476ef61f85ec3aa26818d094a1 Mon Sep 17 00:00:00 2001
+From: David Phillips <dbphillipsnz@gmail.com>
+Date: Thu, 12 Feb 2015 11:56:35 +1300
+Subject: [PATCH 2/9] Blank the screen with color 0, add third color for failed
+ logins
+
+- Adds another color in config.def.h, COLOR_INIT
+- Renames the colours from numerical ones to ones with meaningful names;
+ COLOR_INPUT for when there is content in the input buffer and COLOR_EMPTY
+ for when the input buffer has been cleared (backspaced or a failed attempt).
+- Ensures XFreeColors frees the right number of colours. This is now derived
+ from the size of `Lock->colors` rather than being an integer literal.
+- Makes slock exhibit the behaviour described by Markus
+
+The default colours are the same as the ones slock currently uses, with the
+exception of the new color, which I have set to red, as it indicates someone
+has either failed an attempt to unlock, or that they have entered input and
+erased it all.
+---
+ config.def.h | 7 +++++--
+ slock.c | 27 ++++++++++++++++++---------
+ 2 files changed, 23 insertions(+), 11 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 89e5977..4bccb5d 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -1,2 +1,5 @@
+-#define COLOR1 "black"
+-#define COLOR2 "#005577"
++static const char *colorname[NUMCOLS] = {
++ "black", /* after initialization */
++ "#005577", /* during input */
++ "#CC3333", /* failed/cleared the input */
++};
+diff --git a/slock.c b/slock.c
+index 407a540..df5c3fe 100644
+--- a/slock.c
++++ b/slock.c
+@@ -22,13 +22,20 @@
+ #include <bsd_auth.h>
+ #endif
+
++enum {
++ INIT,
++ INPUT,
++ EMPTY,
++ NUMCOLS
++};
++
+ #include "config.h"
+
+ typedef struct {
+ int screen;
+ Window root, win;
+ Pixmap pmap;
+- unsigned long colors[2];
++ unsigned long colors[NUMCOLS];
+ } Lock;
+
+ static Lock **locks;
+@@ -162,12 +169,12 @@ readpw(Display *dpy, const char *pws)
+ }
+ if (llen == 0 && len != 0) {
+ for (screen = 0; screen < nscreens; screen++) {
+- XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[1]);
++ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[INPUT]);
+ XClearWindow(dpy, locks[screen]->win);
+ }
+ } 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[EMPTY]);
+ XClearWindow(dpy, locks[screen]->win);
+ }
+ }
+@@ -185,7 +192,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, NUMCOLS, 0);
+ XFreePixmap(dpy, lock->pmap);
+ XDestroyWindow(dpy, lock->win);
+
+@@ -197,6 +204,7 @@ lockscreen(Display *dpy, int screen)
+ {
+ char curs[] = {0, 0, 0, 0, 0, 0, 0, 0};
+ unsigned int len;
++ int i;
+ Lock *lock;
+ XColor color, dummy;
+ XSetWindowAttributes wa;
+@@ -213,16 +221,17 @@ lockscreen(Display *dpy, int screen)
+
+ lock->root = RootWindow(dpy, lock->screen);
+
++ for (i = 0; i < NUMCOLS; i++) {
++ XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), colorname[i], &color, &dummy);
++ lock->colors[i] = color.pixel;
++ }
++
+ /* init */
+ wa.override_redirect = 1;
+- wa.background_pixel = BlackPixel(dpy, lock->screen);
++ wa.background_pixel = lock->colors[INIT];
+ 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), COLOR2, &color, &dummy);
+- lock->colors[1] = color.pixel;
+- XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR1, &color, &dummy);
+- lock->colors[0] = color.pixel;
+ lock->pmap = XCreateBitmapFromData(dpy, lock->win, curs, 8, 8);
+ invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &color, 0, 0);
+ XDefineCursor(dpy, lock->win, invisible);
+--
+2.6.4
+
diff --git a/desktop/slock/patches/0003-resize-lockscreen-window-after-Xrandr-resize.patch b/desktop/slock/patches/0003-resize-lockscreen-window-after-Xrandr-resize.patch
new file mode 100644
index 0000000000..4b74350fca
--- /dev/null
+++ b/desktop/slock/patches/0003-resize-lockscreen-window-after-Xrandr-resize.patch
@@ -0,0 +1,83 @@
+From f5ef1b8eb5555da11e81d92d8d05acd4aba1ef40 Mon Sep 17 00:00:00 2001
+From: Markus Teich <markus.teich@stusta.mhn.de>
+Date: Wed, 25 Feb 2015 23:06:45 +0100
+Subject: [PATCH 3/9] resize lockscreen window after Xrandr resize
+
+---
+ config.mk | 2 +-
+ slock.c | 18 ++++++++++++++++--
+ 2 files changed, 17 insertions(+), 3 deletions(-)
+
+diff --git a/config.mk b/config.mk
+index 067cfc7..44e41c6 100644
+--- a/config.mk
++++ b/config.mk
+@@ -11,7 +11,7 @@ X11LIB = /usr/X11R6/lib
+
+ # includes and libs
+ INCS = -I. -I/usr/include -I${X11INC}
+-LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext
++LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr
+
+ # flags
+ CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H
+diff --git a/slock.c b/slock.c
+index df5c3fe..6502c86 100644
+--- a/slock.c
++++ b/slock.c
+@@ -13,6 +13,7 @@
+ #include <string.h>
+ #include <unistd.h>
+ #include <sys/types.h>
++#include <X11/extensions/Xrandr.h>
+ #include <X11/keysym.h>
+ #include <X11/Xlib.h>
+ #include <X11/Xutil.h>
+@@ -41,6 +42,9 @@ typedef struct {
+ static Lock **locks;
+ static int nscreens;
+ static Bool running = True;
++static Bool rr;
++static int rrevbase;
++static int rrerrbase;
+
+ static void
+ die(const char *errstr, ...)
+@@ -179,8 +183,15 @@ readpw(Display *dpy, const char *pws)
+ }
+ }
+ llen = len;
+- }
+- else for (screen = 0; screen < nscreens; screen++)
++ } else if (rr && ev.type == rrevbase + RRScreenChangeNotify) {
++ XRRScreenChangeNotifyEvent *rre = (XRRScreenChangeNotifyEvent*)&ev;
++ for (screen = 0; screen < nscreens; screen++) {
++ if (locks[screen]->win == rre->window) {
++ XResizeWindow(dpy, locks[screen]->win, rre->width, rre->height);
++ XClearWindow(dpy, locks[screen]->win);
++ }
++ }
++ } else for (screen = 0; screen < nscreens; screen++)
+ XRaiseWindow(dpy, locks[screen]->win);
+ }
+ }
+@@ -236,6 +247,8 @@ lockscreen(Display *dpy, int screen)
+ invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &color, 0, 0);
+ XDefineCursor(dpy, lock->win, invisible);
+ XMapRaised(dpy, lock->win);
++ if (rr)
++ XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask);
+ for (len = 1000; len; len--) {
+ if (XGrabPointer(dpy, lock->root, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
+ GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess)
+@@ -295,6 +308,7 @@ main(int argc, char **argv) {
+
+ if (!(dpy = XOpenDisplay(0)))
+ die("slock: cannot open display\n");
++ rr = XRRQueryExtension(dpy, &rrevbase, &rrerrbase);
+ /* Get the number of screens in display "dpy" and blank them all. */
+ nscreens = ScreenCount(dpy);
+ locks = malloc(sizeof(Lock *) * nscreens);
+--
+2.6.4
+
diff --git a/desktop/slock/patches/0004-Option-to-not-show-failure-color-on-clear.patch b/desktop/slock/patches/0004-Option-to-not-show-failure-color-on-clear.patch
new file mode 100644
index 0000000000..07866a66c6
--- /dev/null
+++ b/desktop/slock/patches/0004-Option-to-not-show-failure-color-on-clear.patch
@@ -0,0 +1,64 @@
+From b1289f30b79c9c5ea43a9e9c624406d7d0661692 Mon Sep 17 00:00:00 2001
+From: Nick Currier <nick.currier@gmail.com>
+Date: Wed, 6 May 2015 10:18:50 -0600
+Subject: [PATCH 4/9] Option to not show failure color on clear
+
+---
+ config.def.h | 1 +
+ slock.c | 9 ++++++---
+ 2 files changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 4bccb5d..fca0ae0 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -3,3 +3,4 @@ static const char *colorname[NUMCOLS] = {
+ "#005577", /* during input */
+ "#CC3333", /* failed/cleared the input */
+ };
++static const Bool failonclear = True;
+diff --git a/slock.c b/slock.c
+index 6502c86..1551a9e 100644
+--- a/slock.c
++++ b/slock.c
+@@ -26,7 +26,7 @@
+ enum {
+ INIT,
+ INPUT,
+- EMPTY,
++ FAILED,
+ NUMCOLS
+ };
+
+@@ -42,6 +42,7 @@ typedef struct {
+ static Lock **locks;
+ static int nscreens;
+ static Bool running = True;
++static Bool failure = False;
+ static Bool rr;
+ static int rrevbase;
+ static int rrerrbase;
+@@ -153,8 +154,10 @@ readpw(Display *dpy, const char *pws)
+ #else
+ running = !!strcmp(crypt(passwd, pws), pws);
+ #endif
+- if (running)
++ if (running) {
+ XBell(dpy, 100);
++ failure = True;
++ }
+ len = 0;
+ break;
+ case XK_Escape:
+@@ -178,7 +181,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[EMPTY]);
++ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[failure || failonclear ? FAILED : INIT]);
+ XClearWindow(dpy, locks[screen]->win);
+ }
+ }
+--
+2.6.4
+
diff --git a/desktop/slock/patches/0005-consistently-use-with-sizeof.patch b/desktop/slock/patches/0005-consistently-use-with-sizeof.patch
new file mode 100644
index 0000000000..8db4960d68
--- /dev/null
+++ b/desktop/slock/patches/0005-consistently-use-with-sizeof.patch
@@ -0,0 +1,34 @@
+From 10d4e479c5f6d91bf86e15be3a12c6b09c9808be Mon Sep 17 00:00:00 2001
+From: Markus Teich <markus.teich@stusta.mhn.de>
+Date: Fri, 8 May 2015 16:43:13 +0200
+Subject: [PATCH 5/9] consistently use () with sizeof
+
+---
+ slock.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/slock.c b/slock.c
+index 1551a9e..68e813f 100644
+--- a/slock.c
++++ b/slock.c
+@@ -133,7 +133,7 @@ readpw(Display *dpy, const char *pws)
+ while (running && !XNextEvent(dpy, &ev)) {
+ if (ev.type == KeyPress) {
+ buf[0] = 0;
+- num = XLookupString(&ev.xkey, buf, sizeof buf, &ksym, 0);
++ num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0);
+ if (IsKeypadKey(ksym)) {
+ if (ksym == XK_KP_Enter)
+ ksym = XK_Return;
+@@ -168,7 +168,7 @@ readpw(Display *dpy, const char *pws)
+ --len;
+ break;
+ default:
+- if (num && !iscntrl((int) buf[0]) && (len + num < sizeof passwd)) {
++ if (num && !iscntrl((int) buf[0]) && (len + num < sizeof(passwd))) {
+ memcpy(passwd + len, buf, num);
+ len += num;
+ }
+--
+2.6.4
+
diff --git a/desktop/slock/patches/0006-rework-setting-window-color.patch b/desktop/slock/patches/0006-rework-setting-window-color.patch
new file mode 100644
index 0000000000..f1c0903f8c
--- /dev/null
+++ b/desktop/slock/patches/0006-rework-setting-window-color.patch
@@ -0,0 +1,54 @@
+From 754195f8d75586e23d1cc69cad00710802e0cb5d Mon Sep 17 00:00:00 2001
+From: Markus Teich <markus.teich@stusta.mhn.de>
+Date: Fri, 8 May 2015 17:10:15 +0200
+Subject: [PATCH 6/9] rework setting window color
+
+---
+ slock.c | 17 +++++++----------
+ 1 file changed, 7 insertions(+), 10 deletions(-)
+
+diff --git a/slock.c b/slock.c
+index 68e813f..d6053af 100644
+--- a/slock.c
++++ b/slock.c
+@@ -119,11 +119,12 @@ readpw(Display *dpy, const char *pws)
+ {
+ char buf[32], passwd[256];
+ int num, screen;
+- unsigned int len, llen;
++ unsigned int len, color;
+ KeySym ksym;
+ XEvent ev;
++ static int oldc = INIT;
+
+- len = llen = 0;
++ len = 0;
+ running = True;
+
+ /* As "slock" stands for "Simple X display locker", the DPMS settings
+@@ -174,18 +175,14 @@ readpw(Display *dpy, const char *pws)
+ }
+ break;
+ }
+- if (llen == 0 && len != 0) {
++ color = len ? INPUT : (failure || failonclear ? FAILED : INIT);
++ if (oldc != color) {
+ for (screen = 0; screen < nscreens; screen++) {
+- XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[INPUT]);
+- XClearWindow(dpy, locks[screen]->win);
+- }
+- } else if (llen != 0 && len == 0) {
+- for (screen = 0; screen < nscreens; screen++) {
+- XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[failure || failonclear ? FAILED : INIT]);
++ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[color]);
+ XClearWindow(dpy, locks[screen]->win);
+ }
++ oldc = color;
+ }
+- llen = len;
+ } else if (rr && ev.type == rrevbase + RRScreenChangeNotify) {
+ XRRScreenChangeNotifyEvent *rre = (XRRScreenChangeNotifyEvent*)&ev;
+ for (screen = 0; screen < nscreens; screen++) {
+--
+2.6.4
+
diff --git a/desktop/slock/patches/0007-Slightly-safer-OOM-killer-disablement-in-linux.patch b/desktop/slock/patches/0007-Slightly-safer-OOM-killer-disablement-in-linux.patch
new file mode 100644
index 0000000000..8fbde2c31d
--- /dev/null
+++ b/desktop/slock/patches/0007-Slightly-safer-OOM-killer-disablement-in-linux.patch
@@ -0,0 +1,45 @@
+From 0edbd2e0164a8c6cbad415e38083469041f29996 Mon Sep 17 00:00:00 2001
+From: David Phillips <dbphillipsnz@gmail.com>
+Date: Fri, 19 Jun 2015 23:42:15 +1200
+Subject: [PATCH 7/9] Slightly safer OOM killer disablement in linux
+
+---
+ slock.c | 13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/slock.c b/slock.c
+index d6053af..b3bee92 100644
+--- a/slock.c
++++ b/slock.c
+@@ -60,16 +60,27 @@ die(const char *errstr, ...)
+
+ #ifdef __linux__
+ #include <fcntl.h>
++#include <linux/oom.h>
+
+ static void
+ dontkillme(void)
+ {
+ int fd;
++ int length;
++ char value[64];
+
+ fd = open("/proc/self/oom_score_adj", O_WRONLY);
+ if (fd < 0 && errno == ENOENT)
+ return;
+- if (fd < 0 || write(fd, "-1000\n", 6) != 6 || close(fd) != 0)
++
++ /* convert OOM_SCORE_ADJ_MIN to string for writing */
++ length = snprintf(value, sizeof(value), "%d\n", OOM_SCORE_ADJ_MIN);
++
++ /* bail on truncation */
++ if (length >= sizeof(value))
++ die("buffer too small\n");
++
++ if (fd < 0 || write(fd, value, length) != length || close(fd) != 0)
+ die("cannot disable the out-of-memory killer for this process\n");
+ }
+ #endif
+--
+2.6.4
+
diff --git a/desktop/slock/patches/0008-Don-t-change-to-failure-colour-on-success.patch b/desktop/slock/patches/0008-Don-t-change-to-failure-colour-on-success.patch
new file mode 100644
index 0000000000..39c70926b7
--- /dev/null
+++ b/desktop/slock/patches/0008-Don-t-change-to-failure-colour-on-success.patch
@@ -0,0 +1,25 @@
+From b95ee111c7625375716e848ec81af2f57ca35b02 Mon Sep 17 00:00:00 2001
+From: David Phillips <dbphillipsnz@gmail.com>
+Date: Thu, 27 Aug 2015 06:16:25 +0200
+Subject: [PATCH 8/9] Don't change to failure colour on success
+
+---
+ slock.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/slock.c b/slock.c
+index b3bee92..6be8f22 100644
+--- a/slock.c
++++ b/slock.c
+@@ -187,7 +187,7 @@ readpw(Display *dpy, const char *pws)
+ break;
+ }
+ color = len ? INPUT : (failure || failonclear ? FAILED : INIT);
+- if (oldc != color) {
++ if (running && oldc != color) {
+ for (screen = 0; screen < nscreens; screen++) {
+ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[color]);
+ XClearWindow(dpy, locks[screen]->win);
+--
+2.6.4
+
diff --git a/desktop/slock/patches/0009-add-option-to-run-command-after-screen-is-locked.patch b/desktop/slock/patches/0009-add-option-to-run-command-after-screen-is-locked.patch
new file mode 100644
index 0000000000..574396a1de
--- /dev/null
+++ b/desktop/slock/patches/0009-add-option-to-run-command-after-screen-is-locked.patch
@@ -0,0 +1,49 @@
+From e867c38123175d6f050e051ee6b00f4737a9712a Mon Sep 17 00:00:00 2001
+From: Markus Teich <markus.teich@stusta.mhn.de>
+Date: Sat, 26 Dec 2015 13:13:25 +0100
+Subject: [PATCH 9/9] add option to run command after screen is locked
+
+---
+ slock.c | 12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/slock.c b/slock.c
+index 6be8f22..ddf1074 100644
+--- a/slock.c
++++ b/slock.c
+@@ -289,7 +289,7 @@ lockscreen(Display *dpy, int screen)
+ static void
+ usage(void)
+ {
+- fprintf(stderr, "usage: slock [-v]\n");
++ fprintf(stderr, "usage: slock [-v|POST_LOCK_CMD]\n");
+ exit(1);
+ }
+
+@@ -303,7 +303,8 @@ main(int argc, char **argv) {
+
+ if ((argc == 2) && !strcmp("-v", argv[1]))
+ die("slock-%s, © 2006-2015 slock engineers\n", VERSION);
+- else if (argc != 1)
++
++ if ((argc == 2) && !strcmp("-h", argv[1]))
+ usage();
+
+ #ifdef __linux__
+@@ -339,6 +340,13 @@ main(int argc, char **argv) {
+ return 1;
+ }
+
++ if (argc >= 2 && fork() == 0) {
++ if (dpy)
++ close(ConnectionNumber(dpy));
++ execvp(argv[1], argv+1);
++ die("slock: execvp %s failed: %s\n", argv[1], strerror(errno));
++ }
++
+ /* Everything is now blank. Now wait for the correct password. */
+ #ifdef HAVE_BSD_AUTH
+ readpw(dpy);
+--
+2.6.4
+
diff --git a/desktop/slock/config.mk.patch b/desktop/slock/patches/config.mk.patch
index b1c5821101..b1c5821101 100644
--- a/desktop/slock/config.mk.patch
+++ b/desktop/slock/patches/config.mk.patch
diff --git a/desktop/slock/slock-1.2-failcolor.diff b/desktop/slock/slock-1.2-failcolor.diff
deleted file mode 100644
index 3b2a03193f..0000000000
--- a/desktop/slock/slock-1.2-failcolor.diff
+++ /dev/null
@@ -1,62 +0,0 @@
-diff --git a/config.def.h b/config.def.h
-index 89e5977..7f55466 100644
---- a/config.def.h
-+++ b/config.def.h
-@@ -1,2 +1,3 @@
- #define COLOR1 "black"
- #define COLOR2 "#005577"
-+#define COLOR3 "#550000"
-diff --git a/slock.c b/slock.c
-index face75e..8519ce2 100644
---- a/slock.c
-+++ b/slock.c
-@@ -29,12 +29,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, ...) {
-@@ -135,6 +136,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)
-@@ -162,7 +164,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);
- }
- }
-@@ -179,7 +181,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);
-
-@@ -212,6 +214,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);
diff --git a/desktop/slock/slock.SlackBuild b/desktop/slock/slock.SlackBuild
index 0b51ea5f65..e40ee6aefb 100644
--- a/desktop/slock/slock.SlackBuild
+++ b/desktop/slock/slock.SlackBuild
@@ -24,7 +24,7 @@
PRGNAM=slock
VERSION=${VERSION:-1.2}
-BUILD=${BUILD:-2}
+BUILD=${BUILD:-3}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
@@ -71,14 +71,19 @@ find -L . \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
-# Support upstream failcolor patch
-# http://tools.suckless.org/slock/patches/failcolor
-if [ "${FAILCOLOR:-no}" != "no" ]; then
- patch -p1 <$CWD/slock-1.2-failcolor.diff
-fi
-
# This uses our CFLAGS defined above
-sed "s/@SLACKCFLAGS@/$SLKCFLAGS/" $CWD/config.mk.patch | patch -p1
+sed "s,@SLACKCFLAGS@,$SLKCFLAGS," $CWD/patches/config.mk.patch | patch -p1
+
+# Upstream patches in git
+patch -p1 < $CWD/patches/0001-applied-Dimitris-style-patch-from-Dec-14-with-some-m.patch
+patch -p1 < $CWD/patches/0002-Blank-the-screen-with-color-0-add-third-color-for-fa.patch
+patch -p1 < $CWD/patches/0003-resize-lockscreen-window-after-Xrandr-resize.patch
+patch -p1 < $CWD/patches/0004-Option-to-not-show-failure-color-on-clear.patch
+patch -p1 < $CWD/patches/0005-consistently-use-with-sizeof.patch
+patch -p1 < $CWD/patches/0006-rework-setting-window-color.patch
+patch -p1 < $CWD/patches/0007-Slightly-safer-OOM-killer-disablement-in-linux.patch
+patch -p1 < $CWD/patches/0008-Don-t-change-to-failure-colour-on-success.patch
+patch -p1 < $CWD/patches/0009-add-option-to-run-command-after-screen-is-locked.patch
make PREFIX=/usr X11INC=/usr/include/X11 X11LIB=/usr/lib${LIBDIRSUFFIX}/X11
make install PREFIX=/usr X11INC=/usr/include/X11 X11LIB=/usr/lib${LIBDIRSUFFIX}/X11 DESTDIR=$PKG