sites

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

slock-secret-password-1.4.diff (963B)


      1 diff --git a/config.def.h b/config.def.h
      2 index 9855e21..989ca08 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -10,3 +10,10 @@ static const char *colorname[NUMCOLS] = {
      6  
      7  /* treat a cleared input like a wrong password (color) */
      8  static const int failonclear = 1;
      9 +
     10 +/* length of entires in scom  */s
     11 +static const int entrylen = 1;
     12 +
     13 +static const secretpass scom[entrylen] = {
     14 +/*	 Password				command */
     15 +	{ "shutdown",           "doas poweroff" },};
     16 diff --git a/slock.c b/slock.c
     17 index d2f0886..6a96a2d 100644
     18 --- a/slock.c
     19 +++ b/slock.c
     20 @@ -160,6 +160,13 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
     21  			case XK_Return:
     22  				passwd[len] = '\0';
     23  				errno = 0;
     24 +
     25 +				for (int i = 0; i < entrylen; i++){
     26 +					if (strcmp(scom[i].pass, passwd) == 0){
     27 +						system(scom[i].command);
     28 +					}
     29 +				}
     30 +
     31  				if (!(inputhash = crypt(passwd, hash)))
     32  					fprintf(stderr, "slock: crypt: %s\n", strerror(errno));
     33  				else