Introduction
Introduction Statistics Contact Development Disclaimer Help
[slock][patch][squares-password]Add squares-password patch - sites - public wik…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
commit d8d8254a7c029dd099577f2dfc564f2fe99aa07c
parent 28b1a4a1dabbf5d8832f69b107fae2389269dbbc
Author: jack-avery <[email protected]>
Date: Tue, 15 Apr 2025 00:58:31 -0400
[slock][patch][squares-password]Add squares-password patch
Diffstat:
M tools.suckless.org/slock/patches/s… | 5 +++++
A tools.suckless.org/slock/patches/s… | 88 +++++++++++++++++++++++++++…
2 files changed, 93 insertions(+), 0 deletions(-)
---
diff --git a/tools.suckless.org/slock/patches/squares/index.md b/tools.suckless…
@@ -15,6 +15,11 @@ Download
--------
* [slock-squares-1.5.diff](slock-squares-1.5.diff)
+Apply the following patch on top of the previous to have the number of squares…
+
+* [slock-squares-password-1.5.diff](slock-squares-password-1.5.diff)
+
Authors
-------
* bsuth - <[email protected]>
+* Jack Avery - <[email protected]> (input patch)
diff --git a/tools.suckless.org/slock/patches/squares/slock-squares-password-1.…
@@ -0,0 +1,88 @@
+diff -up ./config.def.h ../config.def.h
+--- ./config.def.h 2025-04-15 00:55:12.710000000 -0400
++++ ../config.def.h 2025-04-15 00:55:54.790000000 -0400
+@@ -10,3 +10,6 @@ static const int failonclear = 1;
+
+ /* size of square in px */
+ static const int squaresize = 50;
++
++/* spacing between squares in px */
++static const int squarespacing = 10;
+diff -up ./slock.c ../slock.c
+--- ./slock.c 2025-04-15 00:55:12.710000000 -0400
++++ ../slock.c 2025-04-15 00:54:09.660000000 -0400
+@@ -130,7 +130,7 @@ gethash(void)
+
+ static void
+ draw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
+- unsigned int color)
++ unsigned int len, unsigned int color)
+ {
+ int screen, crtc;
+ XRRCrtcInfo* rrci;
+@@ -145,14 +145,19 @@ draw(Display *dpy, struct xrandr *rr, st
+ locks[screen]->rrsr,
+ locks[screen]->rrsr->cr…
+ /* skip disabled crtc */
+- if (rrci->noutput > 0)
+- XFillRectangle(dpy,
+- locks[screen]->win,
+- locks[screen]->gc,
+- rrci->x + (rrci->width…
+- rrci->y + (rrci->heigh…
+- squaresize,
+- squaresize);
++ if (rrci->noutput > 0) {
++ if (len < 1)
++ len = 1;
++ int xoffset = (int) ((squaresize * le…
++ for (int i = 0; i < len; i++)
++ XFillRectangle(dpy,
++ locks[screen]-…
++ locks[screen]-…
++ rrci->x - xoff…
++ rrci->y + (rrc…
++ squaresize,
++ squaresize);
++ }
+ XRRFreeCrtcInfo(rrci);
+ }
+ }
+@@ -172,7 +177,7 @@ readpw(Display *dpy, struct xrandr *rr,
+ {
+ XRRScreenChangeNotifyEvent *rre;
+ char buf[32], passwd[256], *inputhash;
+- int num, screen, running, failure, oldc;
++ int num, screen, running, failure;
+ unsigned int len, color;
+ KeySym ksym;
+ XEvent ev;
+@@ -180,7 +185,6 @@ readpw(Display *dpy, struct xrandr *rr,
+ len = 0;
+ running = 1;
+ failure = 0;
+- oldc = INIT;
+
+ while (running && !XNextEvent(dpy, &ev)) {
+ if (ev.type == KeyPress) {
+@@ -230,9 +234,8 @@ readpw(Display *dpy, struct xrandr *rr,
+ break;
+ }
+ color = len ? INPUT : ((failure || failonclear) ? FAI…
+- if (running && oldc != color) {
+- draw(dpy, rr, locks, nscreens, color);
+- oldc = color;
++ if (running) {
++ draw(dpy, rr, locks, nscreens, len, color);
+ }
+ } else if (rr->active && ev.type == rr->evbase + RRScreenChan…
+ rre = (XRRScreenChangeNotifyEvent*)&ev;
+@@ -428,7 +431,7 @@ main(int argc, char **argv) {
+ }
+
+ /* draw the initial rectangle */
+- draw(dpy, &rr, locks, nscreens, INIT);
++ draw(dpy, &rr, locks, nscreens, 0, INIT);
+
+ /* everything is now blank. Wait for the correct password */
+ readpw(dpy, &rr, locks, nscreens, hash);
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.