[wiki] [sites] wiki updated

From: <hg_AT_suckless.org>
Date: Fri, 20 Nov 2009 10:25:10 +0000 (UTC)

changeset: 373:52a01fbf7bdc
tag: tip
user: x_AT_eol.org
date: Fri Nov 20 11:25:33 2009 +0100
files: surf.suckless.org/files/simple_bookmarking.md tools.suckless.org/dmenu/patches/dmenu-ms_nl.diff tools.suckless.org/dmenu/patches/dmenu_xmms.diff tools.suckless.org/dmenu/patches/multiselect_and_newline.md tools.suckless.org/dmenu/patches/xmms-like_pattern_matching.md
description:
added tools.suckless.org/dmenu/patches/dmenu-ms_nl.diff
added tools.suckless.org/dmenu/patches/dmenu_xmms.diff
added tools.suckless.org/dmenu/patches/multiselect_and_newline.md
added tools.suckless.org/dmenu/patches/xmms-like_pattern_matching.md
changed surf.suckless.org/files/simple_bookmarking.md


diff -r e8bffba8f4c5 -r 52a01fbf7bdc surf.suckless.org/files/simple_bookmarking.md
--- a/surf.suckless.org/files/simple_bookmarking.md Thu Nov 19 14:22:40 2009 +0100
+++ b/surf.suckless.org/files/simple_bookmarking.md Fri Nov 20 11:25:33 2009 +0100
_AT_@ -4,32 +4,46 @@
 Description
 -----------
 
-This script assumes the simpliest surf usage, which probably will not be yours,
 change this script to fit your needs.
 
-Make sure surf is launched with something like that :
-surf -x >> ~/.surf/id
-
 bookmarkurl :
 
+ #!/bin/sh
         file=~/.surf/bookmarks
- surfid=`head -n 1 ~/.surf/id`
- url=`xprop -id $surfid | grep URL | awk '{print $3}' | sed 's/\"/\ /g'`
- title=`xprop -id $surfid | grep WM_ICON_NAME\(STRING\) | cut -c 24-`
- echo -e `echo -e $url $title | dmenu` >> $file
+ url=`xprop -id $1 | grep URL | awk '{print $3}' | sed 's/\"//g'`
+ title=`xprop -id $1 | grep WM_ICON_NAME\(STRING\) | cut -c 24-`
+ echo $url $title | dmenu -nl >> $file
  
-
-to add tags, when dmenu displays, simply tab, space and write your tag
+to add tags, when dmenu displays, simply tab, space and write your tag.
+
+
 
 loadbookmark :
 (needs a vertical patch on dmenu for convenience, choose the one you like,
 Meillo's is the lightweight, Fresch's is the full featured)
 
- url=`cat ~/.surf/bookmarks | dmenu -i -b -l 10 | awk '{print $1}'`
- xprop -id `head -n 1 ~/.surf/id` -f _SURF_URL 8s -set _SURF_URL $url
+ #!/bin/sh
+ cat ~/.surf/bookmarks | dmenu -i -b -l 10 | awk '{print $1}'
 
 To make dmenu display bookmark with a tag only, add a grep part in the
 first line and launch this script with the tag as argument.
+
+bookmarkurl and loadbookmark can be launched with the following in config.h above the
+"static Key keys[] = {" line :
+
+ #define ADDBMK { .v = (char *[]){ "/bin/sh", "-c", \
+ "bookmarkurl $0", winid, NULL } }
+ #define LOADBMK(p) { .v = (char *[]){ "/bin/sh", "-c", \
+ "xprop -id $1 -f $0 8s -set $0 `loadbookmark` || exit 0", \
+ p, winid, NULL } }
+
+and
+
+ { MODKEY, GDK_a, spawn, ADDBMK },
+ { MODKEY, GDK_b, spawn, LOADBMK("_SURF_URI") },
+
+in the "static Key keys[] = {" part.
+
  
 Author
 ------
diff -r e8bffba8f4c5 -r 52a01fbf7bdc tools.suckless.org/dmenu/patches/dmenu-ms_nl.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools.suckless.org/dmenu/patches/dmenu-ms_nl.diff Fri Nov 20 11:25:33 2009 +0100
_AT_@ -0,0 +1,79 @@
+diff -up dmenu-4.0/dmenu.1 dmenu-4.0_ms_nl/dmenu.1
+--- dmenu-4.0/dmenu.1 2009-04-18 13:50:04.000000000 +0200
++++ dmenu-4.0_ms_nl/dmenu.1 2009-11-19 23:01:15.000000000 +0100
+_AT_@ -11,6 +11,8 @@ dmenu \- dynamic menu
+ .RB [ \-p " <prompt>"]
+ .RB [ \-sb " <color>"]
+ .RB [ \-sf " <color>"]
++.RB [ \-ms ]
++.RB [ \-nl ]
+ .RB [ \-v ]
+ .SH DESCRIPTION
+ .SS Overview
+_AT_@ -44,6 +46,12 @@ defines the selected background color (#
+ .B \-sf <color>
+ defines the selected foreground color (#RGB, #RRGGBB, and color names are supported).
+ .TP
++.B \-ms
++multi-select; selecting an item and pressing return won't terminate dmenu.
++.TP
++.B \-nl
++seperates standard output by newlines.
++.TP
+ .B \-v
+ prints version information to standard output, then exits.
+ .SH USAGE
+diff -up dmenu-4.0/dmenu.c dmenu-4.0_ms_nl/dmenu.c
+--- dmenu-4.0/dmenu.c 2009-04-18 13:50:04.000000000 +0200
++++ dmenu-4.0_ms_nl/dmenu.c 2009-11-19 23:04:59.000000000 +0100
+_AT_@ -69,6 +69,7 @@ static int textw(const char *text);
+ /* variables */
+ static char *maxname = NULL;
+ static char *prompt = NULL;
++static char *nl = "";
+ static char text[4096];
+ static int cmdw = 0;
+ static int promptw = 0;
+_AT_@ -77,6 +78,7 @@ static int screen;
+ static unsigned int mw, mh;
+ static unsigned int numlockmask = 0;
+ static Bool running = True;
++static Bool multiselect = False;
+ static Display *dpy;
+ static DC dc;
+ static Item *allitems = NULL; /* first of all items */
+_AT_@ -448,13 +450,13 @@ kpress(XKeyEvent * e) {
+ break;
+ case XK_Return:
+ if((e->state & ShiftMask) && *text)
+- fprintf(stdout, "%s", text);
++ fprintf(stdout, "%s%s", text, nl);
+ else if(sel)
+- fprintf(stdout, "%s", sel->text);
++ fprintf(stdout, "%s%s", sel->text, nl);
+ else if(*text)
+- fprintf(stdout, "%s", text);
++ fprintf(stdout, "%s%s", text, nl);
+ fflush(stdout);
+- running = False;
++ running = multiselect;
+ break;
+ case XK_Right:
+ if(!(sel && sel->right))
+_AT_@ -694,11 +696,15 @@ main(int argc, char *argv[]) {
+ else if(!strcmp(argv[i], "-sf")) {
+ if(++i < argc) selfgcolor = argv[i];
+ }
++ else if(!strcmp(argv[i], "-ms"))
++ multiselect = True;
++ else if(!strcmp(argv[i], "-nl"))
++ nl = "\n";
+ 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>] [-ms] [-nl] [-v]\n");
+ if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
+ fprintf(stderr, "warning: no locale support\n");
+ if(!(dpy = XOpenDisplay(NULL)))
diff -r e8bffba8f4c5 -r 52a01fbf7bdc tools.suckless.org/dmenu/patches/dmenu_xmms.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools.suckless.org/dmenu/patches/dmenu_xmms.diff Fri Nov 20 11:25:33 2009 +0100
_AT_@ -0,0 +1,133 @@
+diff -up dmenu-4.0/config.h dmenu-4.0_xmms/config.h
+--- dmenu-4.0/config.h 2009-04-18 13:50:04.000000000 +0200
++++ dmenu-4.0_xmms/config.h 2009-11-19 21:31:17.000000000 +0100
+_AT_@ -7,3 +7,4 @@ static const char *normfgcolor = "#00000
+ static const char *selbgcolor = "#0066ff";
+ static const char *selfgcolor = "#ffffff";
+ static unsigned int spaceitem = 30; /* px between menu items */
++static unsigned int maxtokens = 16; /* max. tokens for pattern matching */
+diff -up dmenu-4.0/dmenu.1 dmenu-4.0_xmms/dmenu.1
+--- dmenu-4.0/dmenu.1 2009-04-18 13:50:04.000000000 +0200
++++ dmenu-4.0_xmms/dmenu.1 2009-11-19 21:14:24.000000000 +0100
+_AT_@ -11,6 +11,7 @@ dmenu \- dynamic menu
+ .RB [ \-p " <prompt>"]
+ .RB [ \-sb " <color>"]
+ .RB [ \-sf " <color>"]
++.RB [ \-xs ]
+ .RB [ \-v ]
+ .SH DESCRIPTION
+ .SS Overview
+_AT_@ -44,6 +45,9 @@ defines the selected background color (#
+ .B \-sf <color>
+ defines the selected foreground color (#RGB, #RRGGBB, and color names are supported).
+ .TP
++.B \-xs
++xmms-like pattern matching.
++.TP
+ .B \-v
+ prints version information to standard output, then exits.
+ .SH USAGE
+diff -up dmenu-4.0/dmenu.c dmenu-4.0_xmms/dmenu.c
+--- dmenu-4.0/dmenu.c 2009-04-18 13:50:04.000000000 +0200
++++ dmenu-4.0_xmms/dmenu.c 2009-11-19 21:56:30.000000000 +0100
+_AT_@ -69,6 +69,7 @@ static int textw(const char *text);
+ /* variables */
+ static char *maxname = NULL;
+ static char *prompt = NULL;
++static char **tokens = NULL;
+ static char text[4096];
+ static int cmdw = 0;
+ static int promptw = 0;
+_AT_@ -77,6 +78,7 @@ static int screen;
+ static unsigned int mw, mh;
+ static unsigned int numlockmask = 0;
+ static Bool running = True;
++static Bool xmms = False;
+ static Display *dpy;
+ static DC dc;
+ static Item *allitems = NULL; /* first of all items */
+_AT_@ -475,22 +477,55 @@ kpress(XKeyEvent * e) {
+ drawmenu();
+ }
+
++unsigned int tokenize(char *pat, char **tok)
++{
++ unsigned int i = 0;
++ char tmp[4096] = {0};
++
++ strncpy(tmp, pat, strlen(pat));
++ tok[0] = strtok(tmp, " ");
++
++ while(tok[i] && i < maxtokens)
++ tok[++i] = strtok(NULL, " ");
++ return i;
++}
++
+ void
+ match(char *pattern) {
+- unsigned int plen;
++ unsigned int plen, tokencnt = 0;
++ char append = 0;
+ Item *i, *itemend, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend;
+
+ if(!pattern)
+ return;
+- plen = strlen(pattern);
++
++ if(!xmms)
++ tokens[(tokencnt = 1)-1] = pattern;
++ else
++ if(!(tokencnt = tokenize(pattern, tokens)))
++ tokens[(tokencnt = 1)-1] = "";
+ item = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL;
+- for(i = allitems; i; i = i->next)
+- if(!fstrncmp(pattern, i->text, plen + 1))
++ for(i = allitems; i; i = i->next) {
++ for(int j = 0; j < tokencnt; ++j) {
++ plen = strlen(tokens[j]);
++ if(!fstrncmp(tokens[j], i->text, plen + 1))
++ append = !append || append > 1 ? 1 : append;
++ else if(!fstrncmp(tokens[j], i->text, plen ))
++ append = !append || append > 2 ? 2 : append;
++ else if(fstrstr(i->text, tokens[j]))
++ append = append > 0 && append < 3 ? append : 3;
++ else {
++ append = 0;
++ break;
++ }
++ }
++ if(append == 1)
+ appenditem(i, &lexact, &exactend);
+- else if(!fstrncmp(pattern, i->text, plen))
++ else if(append == 2)
+ appenditem(i, &lprefix, &prefixend);
+- else if(fstrstr(i->text, pattern))
++ else if(append == 3)
+ appenditem(i, &lsubstr, &substrend);
++ }
+ if(lexact) {
+ item = lexact;
+ itemend = exactend;
+_AT_@ -643,6 +678,7 @@ setup(Bool topbar) {
+ if(promptw > mw / 5)
+ promptw = mw / 5;
+ text[0] = 0;
++ tokens = malloc((xmms?maxtokens:1)*sizeof(char*));
+ match(text);
+ XMapRaised(dpy, win);
+ }
+_AT_@ -694,11 +730,13 @@ main(int argc, char *argv[]) {
+ else if(!strcmp(argv[i], "-sf")) {
+ if(++i < argc) selfgcolor = argv[i];
+ }
++ else if(!strcmp(argv[i], "-xs"))
++ xmms = True;
+ 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>] [-xs] [-v]\n");
+ if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
+ fprintf(stderr, "warning: no locale support\n");
+ if(!(dpy = XOpenDisplay(NULL)))
diff -r e8bffba8f4c5 -r 52a01fbf7bdc tools.suckless.org/dmenu/patches/multiselect_and_newline.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools.suckless.org/dmenu/patches/multiselect_and_newline.md Fri Nov 20 11:25:33 2009 +0100
_AT_@ -0,0 +1,19 @@
+MULTISELECT AND NEWLINE
+=======================
+
+multi-select: selecting an item and pressing return won't terminate dmenu
+newline : seperates standard outputs by newlines
+
+These two features are enabled by -ms and -nl command line flag, they can be useful in scripts where one wishes to print several elements from a list
+with new line in between.
+
+The code comes from a vertical patch for dmenu_3.9 wrote by Fresch, the original patch has a lot of options, I just cutted out the one I use on top of Meillo's dmenu vertical patch. (these two and xmms-like pattern matching for huge strings)
+
+Cutter
+------
+- Julien Steinhauser <[julien.steinhauser_AT_orange.fr](mailto:julien.steinhauser_AT_orange.fr)>
+
+Download
+--------
+
+* [dmenu-ms_nl.diff](dmenu-ms_nl.diff)
diff -r e8bffba8f4c5 -r 52a01fbf7bdc tools.suckless.org/dmenu/patches/xmms-like_pattern_matching.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools.suckless.org/dmenu/patches/xmms-like_pattern_matching.md Fri Nov 20 11:25:33 2009 +0100
_AT_@ -0,0 +1,26 @@
+XMMS-LIKE PATTERN MATCHING
+==========================
+
+This patch allows the user to match strings in several pieces.
+For example to type:
+
+ dme atc
+
+could match
+
+ http://tools.suckless.org/dmenu/patches/
+
+ in someone's bookmarks file.
+
+This feature is enabled by -xs command line flag, it can be useful to ease the matching on huge strings.
+
+The code comes from a vertical patch for dmenu_3.9 wrote by Fresch, the original patch has a lot of options, I just cutted out the ones I use on top of Meillo's dmenu vertical patch. (multiselect, newline and this one)
+
+Cutter
+------
+- Julien Steinhauser <[julien.steinhauser_AT_orange.fr](mailto:julien.steinhauser_AT_orange.fr)>
+
+Download
+--------
+
+* [dmenu_xmms.diff](dmenu_xmms.diff)
Received on Fri Nov 20 2009 - 11:25:10 CET

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:31:00 CEST