[wiki] [sites] Add patch "dmenu-dynamicoptions" || Tiago Teles

From: <git_AT_suckless.org>
Date: Tue, 26 May 2020 20:07:35 +0200

commit 39f12c7f0d14c8a9fff7c6cc912f1c387523c5bc
Author: Tiago Teles <tiago.sequeira.teles_AT_gmail.com>
Date: Tue May 26 19:06:32 2020 +0100

    Add patch "dmenu-dynamicoptions"

diff --git a/tools.suckless.org/dmenu/patches/dynamicoptions/dmenu-dynamicoptions-20200526-9585ad8.diff b/tools.suckless.org/dmenu/patches/dynamicoptions/dmenu-dynamicoptions-20200526-410003e0.diff
similarity index 62%
rename from tools.suckless.org/dmenu/patches/dynamicoptions/dmenu-dynamicoptions-20200526-9585ad8.diff
rename to tools.suckless.org/dmenu/patches/dynamicoptions/dmenu-dynamicoptions-20200526-410003e0.diff
index 78a020f5..b4ea2144 100644
--- a/tools.suckless.org/dmenu/patches/dynamicoptions/dmenu-dynamicoptions-20200526-9585ad8.diff
+++ b/tools.suckless.org/dmenu/patches/dynamicoptions/dmenu-dynamicoptions-20200526-410003e0.diff
_AT_@ -1,17 +1,17 @@
-From 2b7c611d792da9653e3dbb284f7624ce46bc9f65 Mon Sep 17 00:00:00 2001
+From 410003e0d776f4038befbc3d2483a75c7e59b38f Mon Sep 17 00:00:00 2001
 From: Tiago Teles <tiago.sequeira.teles_AT_gmail.com>
-Date: Tue, 26 May 2020 11:56:29 +0100
-Subject: [PATCH 1/2] '-dy commandhere' option added, where said command will
- be ran every time input changes, with the current output as the first
- argumentand dmenu options will be changed accordingly
+Date: Tue, 26 May 2020 18:49:13 +0100
+Subject: [PATCH] dynamic menu updating added '-dy $command' will run `$command
+ $currentinput` on input change and replace the options on dmenu with the
+ output of said command.
 
 ---
  config.def.h | 1 +
- dmenu.c | 38 +++++++++++++++++++++++++++++++-------
- 2 files changed, 32 insertions(+), 7 deletions(-)
+ dmenu.c | 43 ++++++++++++++++++++++++++++++++++++-------
+ 2 files changed, 37 insertions(+), 7 deletions(-)
 
 diff --git a/config.def.h b/config.def.h
-index 1edb647..035b877 100644
+index 1edb6477..035b8777 100644
 --- a/config.def.h
 +++ b/config.def.h
 _AT_@ -7,6 +7,7 @@ static const char *fonts[] = {
_AT_@ -23,10 +23,10 @@ index 1edb647..035b877 100644
          /* fg bg */
          [SchemeNorm] = { "#bbbbbb", "#222222" },
 diff --git a/dmenu.c b/dmenu.c
-index 6b8f51b..6a0eb01 100644
+index 6b8f51b5..2d7f2178 100644
 --- a/dmenu.c
 +++ b/dmenu.c
-_AT_@ -210,9 +210,28 @@ grabkeyboard(void)
+_AT_@ -210,9 +210,33 @@ grabkeyboard(void)
          die("cannot grab keyboard");
  }
  
_AT_@ -34,15 +34,20 @@ index 6b8f51b..6a0eb01 100644
 +
 +static void
 +refreshoptions(){
-+ int dynlen = strlen(dynamic);
-+ char cmd[dynlen + strlen(text)];
-+ strcpy(cmd, dynamic);
-+ cmd[dynlen] = ' ';
-+ strcpy(&cmd[dynlen] + 1, text);
-+ FILE *stream = popen(cmd, "r");
-+ readstdin(stream);
-+ pclose(stream);
-+ curr = sel = items;
++ int dynlen = strlen(dynamic);
++ char* cmd= malloc(dynlen + strlen(text)+2);
++ if(!cmd || cmd == NULL)
++ die("malloc:");
++ sprintf(cmd,"%s %s",dynamic, text);
++ FILE *stream = popen(cmd, "r");
++ if(!stream)
++ die("popen(%s):",cmd);
++ readstdin(stream);
++ int pc = pclose(stream);
++ if(pc == -1)
++ die("pclose:");
++ free(cmd);
++ curr = sel = items;
 +}
 +
  static void
_AT_@ -55,7 +60,7 @@ index 6b8f51b..6a0eb01 100644
          static char **tokv = NULL;
          static int tokn = 0;
  
-_AT_@ -234,7 +253,7 @@ match(void)
+_AT_@ -234,7 +258,7 @@ match(void)
                  for (i = 0; i < tokc; i++)
                          if (!fstrstr(item->text, tokv[i]))
                                  break;
_AT_@ -64,7 +69,7 @@ index 6b8f51b..6a0eb01 100644
                          continue;
                  /* exact matches go first, then prefixes, then substrings */
                  if (!tokc || !fstrncmp(text, item->text, textsize))
-_AT_@ -519,14 +538,14 @@ paste(void)
+_AT_@ -519,14 +543,14 @@ paste(void)
  }
  
  static void
_AT_@ -81,7 +86,7 @@ index 6b8f51b..6a0eb01 100644
                  if (i + 1 >= size / sizeof *items)
                          if (!(items = realloc(items, (size += BUFSIZ))))
                                  die("cannot realloc %u bytes:", size);
-_AT_@ -544,7 +563,8 @@ readstdin(void)
+_AT_@ -544,7 +568,8 @@ readstdin(void)
          if (items)
                  items[i].text = NULL;
          inputw = items ? TEXTW(items[imax].text) : 0;
_AT_@ -91,7 +96,7 @@ index 6b8f51b..6a0eb01 100644
  }
  
  static void
-_AT_@ -683,7 +703,7 @@ static void
+_AT_@ -683,7 +708,7 @@ static void
  usage(void)
  {
          fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
_AT_@ -100,7 +105,7 @@ index 6b8f51b..6a0eb01 100644
          exit(1);
  }
  
-_AT_@ -726,6 +746,8 @@ main(int argc, char *argv[])
+_AT_@ -726,6 +751,8 @@ main(int argc, char *argv[])
                          colors[SchemeSel][ColFg] = argv[++i];
                  else if (!strcmp(argv[i], "-w")) /* embedding window id */
                          embed = argv[++i];
_AT_@ -109,7 +114,7 @@ index 6b8f51b..6a0eb01 100644
                  else
                          usage();
  
-_AT_@ -754,9 +776,11 @@ main(int argc, char *argv[])
+_AT_@ -754,9 +781,11 @@ main(int argc, char *argv[])
  
          if (fast && !isatty(0)) {
                  grabkeyboard();
_AT_@ -126,48 +131,3 @@ index 6b8f51b..6a0eb01 100644
 --
 2.26.2
 
-
-From 9585ad8921f5fa17c9da0d613ce5fbedf98e18ef Mon Sep 17 00:00:00 2001
-From: Tiago Teles <tiago.sequeira.teles_AT_gmail.com>
-Date: Tue, 26 May 2020 17:08:58 +0100
-Subject: [PATCH 2/2] slight modifications and errors added
-
----
- dmenu.c | 21 ++++++++++++---------
- 1 file changed, 12 insertions(+), 9 deletions(-)
-
-diff --git a/dmenu.c b/dmenu.c
-index 6a0eb01..b7798e7 100644
---- a/dmenu.c
-+++ b/dmenu.c
-_AT_@ -214,15 +214,18 @@ static void readstdin(FILE* stream);
- 
- static void
- refreshoptions(){
--  int dynlen = strlen(dynamic);
--  char cmd[dynlen + strlen(text)];
--  strcpy(cmd, dynamic);
--  cmd[dynlen] = ' ';
--  strcpy(&cmd[dynlen] + 1, text);
--  FILE *stream = popen(cmd, "r");
--  readstdin(stream);
--  pclose(stream);
--  curr = sel = items;
-+	int dynlen = strlen(dynamic);
-+	char* cmd= malloc(dynlen + strlen(text)+2);
-+	sprintf(cmd,"%s %s",dynamic, text);
-+	FILE *stream = popen(cmd, "r");
-+	if(!stream)
-+		die("popen(%s):",cmd);
-+	readstdin(stream);
-+	int pc = pclose(stream);
-+	if(pc == -1)
-+		die("pclose:");
-+	free(cmd);
-+	curr = sel = items;
- }
- 
- static void
--- 
-2.26.2
-
diff --git a/tools.suckless.org/dmenu/patches/dynamicoptions/index.md b/tools.suckless.org/dmenu/patches/dynamicoptions/index.md
index 3de0331c..5f249300 100644
--- a/tools.suckless.org/dmenu/patches/dynamicoptions/index.md
+++ b/tools.suckless.org/dmenu/patches/dynamicoptions/index.md
_AT_@ -16,7 +16,7 @@ in dmenu and lets you select it)
 
 Download
 --------
-* [dmenu-dynamicoptions-20200526-9585ad8.diff](dmenu-dynamicoptions-20200526-9585ad8.diff)
+* [dmenu-dynamicoptions-20200526-410003e0.diff](dmenu-dynamicoptions-20200526-410003e0.diff)
 
 Author
 ------
Received on Tue May 26 2020 - 20:07:35 CEST

This archive was generated by hypermail 2.3.0 : Tue May 26 2020 - 20:12:46 CEST