slock

My build of slock (suckless display locker)
git clone https://git.regexghost.com/slock.git
Log | Files | Refs | README | LICENSE

commit 916aac66354c97c87809d8381837ab96abfd55a3
parent c49fd3084cbab89acc65638c93000b8e5877c2de
Author: regexghost <dev@regexghost.com>
Date:   Fri, 19 Jun 2026 00:22:32 +0100

foreground image patch + correct position

Diffstat:
Mconfig.def.h | 9++++++++-
Mconfig.mk | 2+-
Mslock.c | 18++++++++++++++++++
3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -15,4 +15,11 @@ static const int failonclear = 1; static const int xbell = 0; /* Background image path, should be available to the user above */ -static const char* background_image = "/home/ghost/.config/regexghost/lockscreen.jpg"; +static const char* background_image = "/home/ghost/.config/regexghost/lockscreen-bg.jpg"; + +static const char *imgpath = "/home/ghost/.config/regexghost/lockscreen-fg.xpm"; +static const int imgwidth = 256; +static const int imgheight = 256; +static const int imgoffsetx = 832; +static const int imgoffsety = 412; +static const int showimgonlyatstart = 1; diff --git a/config.mk b/config.mk @@ -12,7 +12,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 -lXrandr -lImlib2 +LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lImlib2 -lXpm # flags CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H diff --git a/slock.c b/slock.c @@ -20,6 +20,7 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <Imlib2.h> +#include <X11/xpm.h> #include "arg.h" #include "util.h" @@ -130,6 +131,19 @@ gethash(void) } static void +showimage(Display *dpy, Window win) +{ + XImage *ximage; + + if (!XpmReadFileToImage (dpy, imgpath, &ximage, NULL, NULL)) { + XSelectInput(dpy, win, ButtonPressMask|ExposureMask); + XMapWindow(dpy, win); + + XPutImage(dpy, win, DefaultGC(dpy, 0), ximage, 0, 0, imgoffsetx, imgoffsety, imgwidth, imgheight); + } +} + +static void readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, const char *hash) { @@ -204,6 +218,8 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, else XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[0]); XClearWindow(dpy, locks[screen]->win); + if (showimgonlyatstart != 1) + showimage(dpy, locks[screen]->win); } oldc = color; } @@ -279,6 +295,8 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen) &color, &color, 0, 0); XDefineCursor(dpy, lock->win, invisible); + showimage(dpy, lock->win); + /* Try to grab mouse pointer *and* keyboard for 600ms, else fail the lock */ for (i = 0, ptgrab = kbgrab = -1; i < 6; i++) { if (ptgrab != GrabSuccess) {