surf browser hints /3

January 9, 2010

another couple of hints about surf, after my previous post.

honestly, I stopped using surf after 0.3 release. I think that the authors stripped out of the code too much sugar that, not being suckless, was nonetheless useful: a status bar showing the current URI, for example. now URI editing is done via xprop and dmenu, which is great piece of software, but not always user friendly (it does not have editing capabilities).

moreover bookmarking is a pain as it relies on external shell scripts. or does it not?

I realized that there is no need to use external shell scripts, as they can be “embedded” in C code. Here is how.

in config.h put these lines, right before the definition of keys[]:

#define BM_PICK { .v = (char *[]){ "/bin/sh", "-c", \
"xprop -id $0 -f _SURF_URI 8s -set _SURF_URI `cat ~/.surf/bookmarks | dmenu || exit 0`", \
winid, NULL } }

#define BM_ADD { .v = (char *[]){ "/bin/sh", "-c", \
"(echo `xprop -id $0 _SURF_URI | cut -d '\"' -f 2` && cat ~/.surf/bookmarks) | sort -u > ~/.surf/bookmarks_new && mv ~/.surf/bookmarks_new ~/.surf/bookmarks", \
winid, NULL } }

then inside keys[] definition, add:

{ MODKEY, GDK_b, spawn, BM_PICK },
{ MODKEY|GDK_SHIFT_MASK,GDK_b, spawn, BM_ADD },

now, recompile. in your shiny new surf, CTRL-B pops-up dmenu with the list of bookmarks and CTRL-SHIFT-B adds the current page to the bookmarks (making sure to remove duplicate entries).

no need for shell scripts!

Advertisements

One Response to “surf browser hints /3”

  1. Andrew Says:

    Hey Lorenzo –

    I put your config.h setup on the suckless wiki, if you want to check it out[1]. Cheers, man!

    [1] http://surf.suckless.org/files/simple_bookmarking_redux


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: