Return to repo list

suckless-gf-dmenu

Gentoo-friendly patches for Suckless's dmenu.
Return to HMagellan.com

instant.patch (1575B)


      1 diff --git a/dmenu.1 b/dmenu.1
      2 index 9eab758..98d3725 100644
      3 --- a/dmenu.1
      4 +++ b/dmenu.1
      5 @@ -3,7 +3,7 @@
      6  dmenu \- dynamic menu
      7  .SH SYNOPSIS
      8  .B dmenu
      9 -.RB [ \-bfiv ]
     10 +.RB [ \-bfinv ]
     11  .RB [ \-l
     12  .IR lines ]
     13  .RB [ \-m
     14 @@ -47,6 +47,9 @@ X until stdin reaches end\-of\-file.
     15  .B \-i
     16  dmenu matches menu items case insensitively.
     17  .TP
     18 +.B \-n
     19 +dmenu instantly selects if only one match.
     20 +.TP
     21  .BI \-l " lines"
     22  dmenu lists items vertically, with the given number of lines.
     23  .TP
     24 diff --git a/dmenu.c b/dmenu.c
     25 index d605ab4..2c2f03e 100644
     26 --- a/dmenu.c
     27 +++ b/dmenu.c
     28 @@ -260,6 +260,13 @@ match(void)
     29  		matchend = substrend;
     30  	}
     31  	curr = sel = matches;
     32 +
     33 +	if(instant && matches && matches==matchend && !lsubstr) {
     34 +		puts(matches->text);
     35 +		cleanup();
     36 +		exit(0);
     37 +	}
     38 +
     39  	calcoffsets();
     40  }
     41  
     42 @@ -636,7 +643,7 @@ setup(void)
     43  static void
     44  usage(void)
     45  {
     46 -	fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
     47 +	fputs("usage: dmenu [-bfinv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
     48  	      "             [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
     49  	exit(1);
     50  }
     51 @@ -659,7 +666,9 @@ main(int argc, char *argv[])
     52  		else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
     53  			fstrncmp = strncasecmp;
     54  			fstrstr = cistrstr;
     55 -		} else if (i + 1 == argc)
     56 +		} else if (!strcmp(argv[i], "-n")) /* instant select only match */
     57 +			instant = 1;
     58 +		else if (i + 1 == argc)
     59  			usage();
     60  		/* these options take one argument */
     61  		else if (!strcmp(argv[i], "-l"))   /* number of lines in vertical list */