Re: [dev] [surf] SearchEngines patch

From: Jessta <jessta_AT_gmail.com>
Date: Thu, 24 Sep 2009 16:28:15 +1000

On 24/09/2009, Nils <mail_AT_n-sch.de> wrote:
> On Thu, Sep 24, 2009 at 10:16:28AM +1000, Jessta wrote:
>> I don't think url parameter replacement is really the domain of the
>> web browser
>
> Oh yeah, you're right. My window manager should do it.
>
I don't think url parameter replacement is really the
domain of the window manager either.

It took a few lines to add this to my bookmarks script.
the $keywordbookmarks file contains something like:

gg http://www.google.com.au/search?q=%s
wiki http://en.wikipedia.org/wiki/Special:Search?search=%s

#!/bin/bash
# load_bookmarks.sh
# the window id of the surf instance must be in $HOME/.surfid
# invoke the script with some kind of key binding
if [ -f $HOME/.dmenurc ]; then
  . $HOME/.dmenurc
else
  DMENU="dmenu -i"
fi

bookmarks=$HOME/.surf/bookmarks
keywordbookmarks=$HOME/.surf/keywordbookmarks
history=$HOME/.surf/history
surfid=`cat $HOME/.surfid`

link=`cat $bookmarks $history | $DMENU ${1+"$@"}` || exit 0
keyword=`echo $link | cut -d' ' -f1`
iskeyword=`cat $keywordbookmarks | grep -w $keyword`
if [ "$?" -eq "0" ]; then
        echo $link
        param=`echo $link | cut -d' ' -f1 --complement|sed -e
's/\:/%3a/g;s/\//%2f/g;s/\?/%3f/g;s/\&/%3d/g;s/\,/%2c/g;s/\[/%5b/g;s/\]/%5d/g;s/
/+/g;s/"/%22/g'`
        link=`cat $keywordbookmarks | grep -w $keyword | cut -d' ' -f2
| sed -e s/%s/$param/`
fi
echo $link >> $history
xprop -id $surfid -f _SURF_URL 8t -set _SURF_URL $link

I'm terrible at bash scripting, but it seems to work.

-- 
=====================
http://jessta.id.au
Received on Thu Sep 24 2009 - 06:28:15 UTC

This archive was generated by hypermail 2.2.0 : Thu Sep 24 2009 - 06:36:02 UTC