sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

slock-alternate-colors-20220921-35633d4.diff (1429B)


      1 From 3603c02bf54df2a5309ac74639829f2393033edc Mon Sep 17 00:00:00 2001
      2 From: Max Schillinger <maxschillinger@web.de>
      3 Date: Wed, 21 Sep 2022 20:23:16 +0200
      4 Subject: [PATCH] Alternate color during password input
      5 
      6 Toggle screen color between two shades of blue during password input to get
      7 some feedback.
      8 ---
      9  config.def.h | 1 +
     10  slock.c      | 4 +++-
     11  2 files changed, 4 insertions(+), 1 deletion(-)
     12 
     13 diff --git a/config.def.h b/config.def.h
     14 index 9855e21..029af10 100644
     15 --- a/config.def.h
     16 +++ b/config.def.h
     17 @@ -5,6 +5,7 @@ static const char *group = "nogroup";
     18  static const char *colorname[NUMCOLS] = {
     19  	[INIT] =   "black",     /* after initialization */
     20  	[INPUT] =  "#005577",   /* during input */
     21 +	[INPUT_ALT] = "#227799", /* during input, second color */
     22  	[FAILED] = "#CC3333",   /* wrong password */
     23  };
     24  
     25 diff --git a/slock.c b/slock.c
     26 index 5ae738c..c4f28b8 100644
     27 --- a/slock.c
     28 +++ b/slock.c
     29 @@ -27,6 +27,7 @@ char *argv0;
     30  enum {
     31  	INIT,
     32  	INPUT,
     33 +	INPUT_ALT,
     34  	FAILED,
     35  	NUMCOLS
     36  };
     37 @@ -187,7 +188,8 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
     38  				}
     39  				break;
     40  			}
     41 -			color = len ? INPUT : ((failure || failonclear) ? FAILED : INIT);
     42 +			color = len ? (len%2 ? INPUT : INPUT_ALT)
     43 +			            : ((failure || failonclear) ? FAILED : INIT);
     44  			if (running && oldc != color) {
     45  				for (screen = 0; screen < nscreens; screen++) {
     46  					XSetWindowBackground(dpy,
     47 -- 
     48 2.37.3
     49