Customizing surf

surf is a simple minimalist web browser based on webkit2gtk by suckless community.

Its user interface does not have any graphical controls like menus and icons. The Ctrl+G shortcut invokes the dmenu program to allow user to enter URL.

In Debian, to install surf,

sudo apt install surf curl suckless-tools

curl is required for downloading files, and suckless-tools contains the dmenu program.

I make some enhancements to surf:

  1. Customizing zoomlevel behavior
  2. Configure a default download location
  3. Enhance the navigation

1. Customizing zoomlevel behavior

To start surf with zoomlevel 2 ,
surf -z 2

One issue I find is that when surf launched a new surf window after clicking a URL, the new surf defaults to zoomlevel 1.

surf.c code is modified to make surf defaults to the zoomlevel it is started with.


2. Configure a default download location

By default, surf downloads file to your home directory. There is no option to change this, and surf does not provide any prompt for user to save the file somewhere else.

The DOWNLOAD(u, r) code in config.def.h is modified to use the variable download as the default download location if it is defined in the user config file ~/.surf/config , otherwise it defaults to the user's home directory.

For example, if ~/.surf/config file contains a line:
download=~/Downloads

surf will now download file to ~/Downloads directory.

Note:
the Debian surf works with any x-terminal-emulator, but the compiled surf from suckless works only with st (a terminal emulator from suckless), which can be installed in Debian with: apt install stterm


3. Enhance the navigation

By default, surf does not have history or bookmarks.

I replace dmenu with my script dmenu-url in config.def.h . The dmenu-url script uses rofi instead of dmenu to provide input/selection of URL.

The script keeps track of user's URL input/selection in a file ~/.local/share/recent_url , where the most recent input is inserted at beginning of file and removed from rest of file. Similarly, it keeps track of find text input/selection in a file ~/.local/share/recent_sfind .

The script then presents this history list so that user can just select a URL when entering a URL.

The location of the history files can be configured by the variable recent_dir in ~/.surf/config file.

Additionally, if the script detects the URL entered is not really a URL, it will perform a search query instead with the condition that the variable search_q is defined in ~/.surf/config file.

For example, to use Google search, set
search_q=http://www.google.com/search?q=


Under Debian, before compiling, required header files have to be installed first:
apt install libwebkit2gtk-4.0-dev libgcr-3-dev

To compile and then install under /usr/local/ with
make clean install

I have the customized surf code @ https://github.com/skyleecm/surf.git


Related:
Building surf browser by suckless on Debian/Ubuntu. Add media streaming support and fix some problems

Git help:

Comments

blog comments powered by Disqus