slock
simple X display locker utility
git clone https://9o.is/git/slock.git
commit 16aac2fdb460a19b328eca15672cf3c9d69d2b61 parent 7afc5518aa5a0f912947afa32b3c30f621a3be63 Author: Jul <jul@9o.is> Date: Thu, 5 Feb 2026 14:47:04 -0500 add message to lock screen with -m flag Diffstat:
| M | config.def.h | | | 1 | + |
| M | config.h | | | 1 | + |
| M | slock.1 | | | 5 | +++++ |
| M | slock.c | | | 11 | +++++++---- |
4 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/config.def.h b/config.def.h @@ -13,4 +13,5 @@ static const int failonclear = 1; static const char *font = "monospace-16"; static const char *fontcolor = "white"; +static const char *message = "Enter Password"; static const char *timer_message = "Locked:"; diff --git a/config.h b/config.h @@ -13,4 +13,5 @@ static const int failonclear = 1; static const char *font = "Fira Mono-18"; static const char *fontcolor = "#E3E3E3"; +static const char *message = "Enter Password"; static const char *timer_message = "LOCKED!"; diff --git a/slock.1 b/slock.1 @@ -8,6 +8,7 @@ .Nm .Op Fl v .Op Fl t Ar seconds +.Op Fl m Ar message .Op Ar cmd Op Ar arg ... .Sh DESCRIPTION .Nm @@ -18,6 +19,10 @@ is executed after the screen has been locked. .Pp The options are as follows: .Bl -tag -width Ds +.It Fl m Ar message +Display custom +.Ar message +on the lock screen. .It Fl t Ar seconds Lock the screen for a minimum of .Ar seconds diff --git a/slock.c b/slock.c @@ -58,6 +58,7 @@ drawtext(Display *dpy, struct lock *lock, const char *text) int w, h, x, y; XGlyphInfo extents; + XClearWindow(dpy, lock->win); if (!lock->xftdraw || !lock->xftfont) return; @@ -115,7 +116,6 @@ locktimer(Display *dpy, struct lock **locks, int nscreens, int timeout) m = remaining / 60; s = remaining % 60; snprintf(timer_text, sizeof(timer_text), "%s %d:%02d remaining", timer_message, m, s); - XClearWindow(dpy, locks[screen]->win); drawtext(dpy, locks[screen], timer_text); } @@ -127,7 +127,7 @@ locktimer(Display *dpy, struct lock **locks, int nscreens, int timeout) } for (screen = 0; screen < nscreens; screen++) - XClearWindow(dpy, locks[screen]->win); + drawtext(dpy, locks[screen], message); } static void @@ -280,7 +280,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[color]); - XClearWindow(dpy, locks[screen]->win); + drawtext(dpy, locks[screen], message); } oldc = color; } @@ -295,7 +295,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, else XResizeWindow(dpy, locks[screen]->win, rre->width, rre->height); - XClearWindow(dpy, locks[screen]->win); + drawtext(dpy, locks[screen], message); break; } } @@ -411,6 +411,9 @@ main(int argc, char **argv) { case 't': timeout = atoi(EARGF(usage())); break; + case 'm': + message = EARGF(usage()); + break; default: usage(); } ARGEND