[Surfraw-devel] contrib for use with uzbl

Sumant Oemrawsingh soemraws at xs4all.nl
Sun Nov 1 15:58:11 UTC 2009


> > I changed it to use the new bookmark locations, but I only gave it a
> > quick test from the shell, not via uzbl. It sort-of worked, but the menu
> > was on a single line and had newline characters displayed in it, they
> > looked like a tiny version of:
> > 
> > N
> >  L
> > 
> > The output of surfraw -elvi now has "GLOBAL ELVI" and "LOCAL ELVI"
> > lines, you may or may not want to strip them from the menu.

I've looked into the issue you said, where you can see the tiny NL characters,
but couldn't find the reason for that. Could it be some kind of encoding
issue (latin-1 v utf-8 or so)? The point of dmenu is that it reads from
standard input and uses each line as a separate menu item. It would seem
strange that it would display the newline as well. Is this tiny NL character a
separate menu item for you? in other words, when dmenu is displaying, can you
"select" one of those items separately, or is it at the beginning/ending of
an elvi name?

Anyway, below is a patch to the script to allow vertical menus (providing you
have installed dmenu with the vertical patch), as well as removing the GLOBAL
ELVI and LOCAL ELVI texts.

-Sumant


diff --git a/examples/uzbl_load_url_from_surfraw b/examples/uzbl_load_url_from_surfraw
index d73c9a7..bf2ef4c 100755
--- a/examples/uzbl_load_url_from_surfraw
+++ b/examples/uzbl_load_url_from_surfraw
@@ -41,6 +41,14 @@ COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
 # Prompt for dmenu
 PROMPT="Open"
 
+# From load_url_from_bookmarks.sh: Use dmenu with vertical patch if available
+if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
+then
+	DMENU="dmenu -i -xs -rs -l 10" # vertical patch
+else
+	DMENU="dmenu -i"
+fi
+
 # Use surfraw to search for the words
 function search()
 {
@@ -69,15 +77,13 @@ function goto()
 # Use dmenu to navigate through possible choices
 function present_menu()
 {
-  elvi=`surfraw -elvi | cut -f 1 | tail --lines=+2`
+  elvi=`surfraw -elvi | grep -v -e ' ELVI:' -e '^W' | cut -f 1`
   if [ -r "$BOOKMARKS" ]
   then
-    bookmarks=" `cut -f 1 -d ' ' "$BOOKMARKS" 2>/dev/null`"
-  else
-    bookmarks=""
+    elvi="$elvi `cut -f 1 -d ' ' "$BOOKMARKS" 2>/dev/null`"
   fi
 
-  echo "${elvi}${bookmarks}" | tr ' ' '\n' | sort | dmenu -p "$PROMPT" -i $COLORS
+  echo "$elvi" | tr ' ' '\n' | sort | $DMENU -p "$PROMPT" $COLORS
 }
 
 present_menu | \






More information about the Surfraw-devel mailing list