[dwm] [patch] flag for default option

From: Dieter Plaetinck <dieter_AT_plaetinck.be>
Date: Sat, 25 Apr 2009 19:27:30 +0200

Hi list.
I'm not a proficient C coder but I managed to hack this patch together.
With this, you can set the starting search string to something else then an empty string.

Dieter

--- dmenu-4.0/dmenu.1 2009-04-18 13:50:04.000000000 +0200
+++ dmenu-4.0-patched/dmenu.1 2009-04-25 19:08:46.000000000 +0200
@@ -23,6 +23,9 @@
 .B \-i
 makes dmenu match menu entries case insensitively.
 .TP
+.B \-d
+set a default value for the search string.
+.TP
 .B \-b
 defines that dmenu appears at the bottom.
 .TP
diff -Naur dmenu-4.0/dmenu.c dmenu-4.0-patched/dmenu.c
--- dmenu-4.0/dmenu.c 2009-04-18 13:50:04.000000000 +0200
+++ dmenu-4.0-patched/dmenu.c 2009-04-25 18:59:46.000000000 +0200
@@ -642,7 +642,6 @@
                 promptw = textw(prompt);
         if(promptw > mw / 5)
                 promptw = mw / 5;
- text[0] = 0;
         match(text);
         XMapRaised(dpy, win);
 }
@@ -667,6 +666,7 @@
 main(int argc, char *argv[]) {
         unsigned int i;
         Bool topbar = True;
+ text[0] = 0;
 
         /* command line args */
         for(i = 1; i < argc; i++)
@@ -694,11 +694,14 @@
                 else if(!strcmp(argv[i], "-sf")) {
                         if(++i < argc) selfgcolor = argv[i];
                 }
+ else if(!strcmp(argv[i], "-d")) {
+ if(++i < argc) strcpy(text, argv[i]);
+ }
                 else if(!strcmp(argv[i], "-v"))
                         eprint("dmenu-"VERSION", 2006-2008 dmenu engineers, see LICENSE for details\n");
                 else
                         eprint("usage: dmenu [-i] [-b] [-fn <font>] [-nb <color>] [-nf <color>]\n"
- " [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");
+ " [-p <prompt>] [-sb <color>] [-sf <color>] [-d <default>] [-v]\n");
         if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
                 fprintf(stderr, "warning: no locale support\n");
         if(!(dpy = XOpenDisplay(NULL)))
Received on Sat Apr 25 2009 - 17:27:30 UTC

This archive was generated by hypermail 2.2.0 : Sat Apr 25 2009 - 17:36:04 UTC