Add bookmarking feature in surf browser (by suckless). How to use bookmarks

This is another note about surf browser (by suckless). Here I will show how to add bookmarking feature.

If you don’t already have an experience building surf browser from the source code, I highly recommend the article: Building surf browser (by suckless) from the source code. !!!!!!!!!!

I wrote there about problems and solutions that you may encounter.

Now we can start.

We need 3 things: the source code, patch utility and patch file (which contains bookmarking feature).

For example, I will use a new source code copy (without any settings applied). But if you edited the config files in the past, you can use your source code copy.

To download a new one I use:

cd /tmp
git clone https://git.suckless.org/surf
cd surf/
ls
...
arg.h     common.h      config.mk  libsurf-webext.c  Makefile  surf.1  surf-open.sh  TODO.md
common.c  config.def.h  FAQ.md     LICENSE           README    surf.c  surf.png

We are in the source code directory now.

The next step is to download patch file. Go to the following page:

https://surf.suckless.org/patches/bookmarking/

And download there the latest patch file available. In my case it is surf-bookmarks-20170722-723ff26.diff (20170722).

Place that file in the source code directory (see above), where are the config files presented:

ls
...
arg.h     common.h      config.mk  libsurf-webext.c  Makefile  surf.1                                surf.c        surf.png
common.c  config.def.h  FAQ.md     LICENSE           README    surf-bookmarks-20170722-723ff26.diff  surf-open.sh  TODO.md

The third step is to make sure that you have patch utility installed in your system. Anyway perform the following command (on Debian-based systems):

sudo apt install --no-install-recommends patch

If patch utility is already installed, it will be updated to the newest version.

Ok, for now we have surf browser’s source code, patch utility and patch file (with bookmarking feature) placed in the source code directory.

If you have config.h modified, copy it to config.def.h (patch utility will use exactly config.def.h file):

cp config.h config.def.h

That way you will save all your settings in config.h and apply bookmarking feature to it.

Now perform the following command (replace .diff filename if differ):

patch -p1 < surf-bookmarks-20170722-723ff26.diff
...
patching file config.def.h
Hunk #1 succeeded at 70 (offset 1 line).
Hunk #2 succeeded at 103 (offset 1 line).
Hunk #3 succeeded at 145 (offset 1 line).

The changes have been applied to config.def.h file.

make utility uses config.h file, so copy config.def.h (patched one) to config.h:

cp config.def.h config.h

Clean the sources directory from the last building:

make clean

Build and install surf browser in the system (with bookmarking feature):

sudo make install

It’s time to test it.

Press Ctrl + G and type the page address that you want to bookmark.

When you hit the page use Ctrl + M to make a bookmark.

For the first time there will be an error in the terminal output which says that bookmarks file is missing. Don’t worry, surf will automatically create it.

Now press Ctrl + G again any type some part of its address:

Surf browser (by suckless) with bookmarking feature. Start to type any part of page’s URL

Press [Enter] and you will hit the page.

Bookmarks file located in ~/.surf/bookmarks, so you can put URL addresses right there.

It is recommended to add https:// prefix to all the pages in this file (to force HTTPS connection).

Leave a Reply

Your email address will not be published.