A collection of patches for the Surf browser
Adds a package build for Arch
Revert back to curl, for other people
Combined patch, which avoids patch conflicts.


browse log



#SER's surf-as-vimb patch

vimb introduced some fantastic features that become indispensible once you get used to them. However, despite also being based on WebKit, vimb struggles with the modern web, moreso than surf does, and more damning, it breaks with its own conventions of plain-textfile-storage and puts cookies into a database. So I've been hacking Surf to be more vimb-like.

This repository contains a couple of scripts and some patches. The surf-*.diff patches may be of use by themselves, but the pieces that I keep maintained and use myself are the vimb-bookmarks-queues.diff patch, and the bm and qq scripts.

The patch combines several patches:

  1. The surf external pipe patch -- this patch is a dependency for the bookmarks and queue patch.
  2. The surf clipboard patch (technically optional)
  3. The history patch (technically optional)
  4. The spacesearch patch (technically optional)
  5. A modified bookmarks patch
  6. My queue support patch

Together, these patches add vimb capabilities to surf.

#Key bindings

Check the static Key keys section in config.def.h and the surf manpage for a complete list; the patch adds these:

  • MOD+d add a bookmark for the current page. A popup dialog asks for a space-separated list of keyword tags to add for the bookmark.
  • MOD+Shift+y select a link in the current page and yank it to the clipboard
  • MOD+w select a link in the current page and go to it (current window)
  • MOD+Shift+w select a link in the current page and go to it in a new window
  • MOD+Return go to a link from the browsing history
  • MOD+backslash pop the top entry off the queue and go to it
  • MOD+Shift+e select a link in the current page and unshift it to the top of the queue
  • MOD+e unshift the current page to the top of the queue

I like to work at the top of the queue, so LIFO. If you prefer to push to the end of the queue but pop from the top (FILO), then edit the config.def.h and swap QPOP() and QUNSHIFT() in the keybindings appropriately.

#The scripts

vimb has three great concepts: bookmarks, queues, and plain-text files.

Most browsers have bookmarks; vimb throws out the document structure, (which IMO is a stupid way to organize bookmarks anyway) and uses tags -- this makes vimb bookmarks more like GMail, and allows arbitrary categorization.

Queues are an obvious, common computer concept which is utterly ignored by most browsers. The closest thing in Chrome or Firefox are save-to-read-later features, which are usually available only as add-ons. In vimb, queues are first-class, and dramatically simplify browsing. If you want to save link to read later in vimb, you don't have to bookmark it (only to remove the bookmark later) or open a tab (using memory and adding to your 100 open tabs): you push the link onto a queue and pop it off later when you're done with whatever you're reading.

Finally, vimb uses flat, plain-text files for most things. Well, almost: bookmarks are TSVs with URL,Title,Tags on each line, but it retains the main feature of being able to be managed with all of the common Unix toolset: sed, awk, grep, and so on.

The two scripts are utility scripts for performing common operations on the queue and bookmarks file. The scripts are not used by the patch, and are only for convenience. With the exception of rofi, they use only tools that are installed on every Linux: awk, sed, and grep.

Neither of these scripts is magical, or particularly hard, or even necessary. The grep command, for instance, trivially runs grep on the file; the only reason to use it is for the tiny convenience of not having to type out the path to the bookmark (or queue) file.


Any operation that modifies the ~/.surf/bookmarks file first creates a backup copy. 10 rotating copies are kept.

USAGE: bm [-v] <cmd> [args]
   tags                    List all tags (sorted, unique)
   grep   <regexp>         Find matching URLs or tags
   backup                  Create a rotated backup of the bookmarks
   clean                   Remove all duplicates (by URL) from the queue. Joins unique tags
   search [opt] <taglist>  Search for all tags matching the list; prints URLs by default.
      -d                   Print the descriptions instead
      -a                   Print the whole line instead
   rm     <regexp>         Remove matches from bookmarks (with confirmation)
   rofi                    Start rofi with the bookmarks
   wc                      Count the number of bookmarks
   help                    Print this help text
   -v                      Enable verbose
   <url> [tags]            Bookmark a URL


qq operations on ~/.surf/queue. It, too, keeps 10 rotating backups of the queue for operations that alter the queue.

USAGE: qq <cmd> [args]
   rot    N         Rotate the last N lines to the top
   top    <regexp>  Move all matching lines to the top
   backup           Create a rotated backup of the queue
   clean            Remove all duplicates from the queue
   grep   <regexp>  Grep in the queue
   rm     <regexp>  Remove matches from queue (with confirmation)
   head   N         Print the first N (5) lines
   tail   N         Print the last N (5) lines
   import           Import URLs from ~/Notes/QuickNote.md
   rofi             Start rofi with the queue
   wc               Count the number of queue entries
   help             Print this help text
          <url>     Push a URL onto the queue