Uzbl

Tutorials >

Here's a light web browser that employs gtkwebkit (as do many others, including Chrome)...  You practically need to build it yourself to get any functionality... Uzbl means "usable"... and I was hoping it would be able to replace my need for chromium for an every-day browser, but it seems to load pages much slower and sometimes hangs.


what is it? http://lwn.net/Articles/341245/ - old page!
https://wiki.archlinux.org/...
http://www.uzbl.org/

above: how a search page looks using a css style sheet (note the background is not white)

It has 
  • a super fast startup
  • many actions possible with keys so it's fast
  • endless possibilities with key-binds
  • no bloat at all
  • searchable history 
  • searchable bookmarks
  • keyword commands, using double Tab to show possible/ Tab to complete
Problems
  • some sites have internal scroll bars which get splattered along the page when scrolling e.g. Google sites :(
  • some web page items don't get rendered
  • flash not working on all sites
  • app can freeze up waiting for load to finish (hence, I suppose, multiple instances of uzbl-browser are the way to go)

install
sudo apt install uzbl suckless-tools youtube-dl

or from the git repos. https://github.com/Dieterbe/uzbl -need to install python3 to compile

config file is in ~/.config/uzbl and it contains layout, key-binds, context menu and proxy settings. = $XDG_CONFIG_HOME/uzbl/config
and data files are in ~/.local/uzbl/ = $XDG_DATA_HOME/uzbl/


My keybinds

(defaults with my mods in bold)
i         toggle insert mode (press to be able to enter text on web pages)
escape return to command mode
o         URL
wo         URL in new tab
O         edit URL
S         stop loading
r         reload
R         reload ignore cache
zs         SSL url
zS         SSL url new tab

ww         new window (new tab if new w =tab is set)
gn           new tab
wc         clone tab
tg+n         go to tab n
              next tab left ....and Alt-Left
]         next tab right ....and Alt-Right
Alt-[       first tab ( <Mod1>[ )
Alt-]       last tab
ZZ, gC close tab
QQ         reset all tabs

fl         spawn numbering of links, enter number to follow one
Fl         " follow in new tab
FL          " to clipboard

Ctrl-m         make bookmark from url
Ctrl-a         insert url from history - I prefer H
Ctrl-z         insert url from bkmark - I prefer B
Ctrl-m [tags]     insert bkmark (doesn't work)

T         hide/show status bar
:         enter command

Ctrl-Left history backward (mine)
Ctrl-Right history forward (mine)
middle button open in new window

j         scroll up, also Up, home
k         scroll down (I changed them round), also Down, end
h         scr horiz left, also $ to end
l         scr horiz right, also ^ to start
G [string] go to on page?

-/+         zoom, T zoom type?
1/2         set zoom level
Ctrl-left     back 
Ctrl-right   forward
/ *         search
? *         search backward
n/N         next search hit
Ctrl-p print page

yu         yank tab url  - I change xclip for xsel or xsel --clipboard
yU         yank selected link url
yy         yank uzbl title
ys         yank follow url

p         load url from primary
'p          "  in new tab
P         load url from clipboard
'P          "  in new tab 

D         temp bkmark (I switched these two round)
Ctrl-d select temp bkmark


Setup

copy the uzbl icon 
sudo cp /usr/share/uzbl/example/data/uzbl.png /usr/share/icons/uzbl.png

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Icon=uzbl.png
Name=uzbl
Exec=uzbl
Comment[en]=web-browser adhering to the unix concepts!
Categories=Network;
MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;


to set uzbl-tabbed to open with "uzbl" command and launcher
cd /usr/bin
 sudo ln -fsT uzbl-tabbed uzbl

in ~/.config/uzbl/config
set new window makes new tab
@on_event   REQ_NEW_WINDOW event NEW_TAB %s

Set the "home" page (end of config file) -but every new tab will open there.


Flash
I'm still not sure about how to enable the flash plugin, whether the gtkwebkit can handle flash by itself somehow??
 -I installed nspluginwrapper - see how to on my Step4 page


Appearance
my changes
set mode_section      = <span background="#303030" foreground="#3B71B7"
set keycmd_section    = <span \@prompt_style>\@[\@keycmd_prompt]\@</span><span \@modcmd_style>\@modcmd</span><span \@keycmd_style>\@keycmd</span><span \@completion_style>\@completion_list</span>
set progress_section  = <span foreground="#4489CC">
set scroll_section    = <span foreground="#3B71B7">\@[\@scroll_message]\@</span>
set uri_section       = <span foreground="#5578A6">\@[\@uri]\@</span>
set status_section    = <span foreground="#4489CC">\@status_message</span>
set selected_section  = <span foreground="#46A4FF">\@[\@SELECTED_URI]\@</span>
etc
set progress.format     = ♦%d%p %c
set progress.done       = ♦

set status_format       = <span font_family="monospace">@mode_section @keycmd_section @progress_section  @scroll_section @selected_section @download_section</span>

Tabs settings http://www.uzbl.org/wiki/uzbl_tabbed

in particular
set new_tab_title           = ..
set max_title_len           = 20
set selected_tab_text       = foreground = "#46A4FF"

to set maximised, with openbox that's easy, or else
 set geometry=maximized 

hide tabs command
@cbind tt = toggle show_tablist 1 0


Styles
-add a dir in the config dir into which you can put css style sheet files, ~/.config/uzbl/css
-make a default style sheet ~/.config/uzbl/css/default.css
-and set it in uzbl config file:
set stylesheet_uri = file://@config_home/uzbl/css/default.css

background colour - to cut out the white!
* { background: #8F6C6C !important; }
that was quite brown, this is better AFAFAF

more background colours are possible, doing it like this (the * in above example sets all of them one color)
body background: #8F6C6C !important; }
h1 {background-color:#6495ed;}
p {background-color:#e0ffff;}
div {background-color:#b0c4de;}

though that's not perfect.

links colours
a:link    { color: #274DC5; }  /* unvisited links */
a:visited { color: #B04684; }  /* visited links   */
a:hover   { color: #B02562; }  /* user hovers     */
a:active  { color: #763652; }  /* active links    */

You can have a unique style sheet for any web site - see the "alternative method" here http://www.uzbl.org/wiki/change_style.sh
Though I'm not sure how to do it yet!


Commands
see the readme page http://www.uzbl.org/readme.php

I changed this line
@on_event   FOCUS_ELEMENT  sh 'if [ "$1" = INPUT -o "$1" = TEXTAREA -o "$1" = SELECT ]; then echo "@set_mode insert" > $UZBL_FIFO; fi' %s
to this
@on_event   FORM_ACTIVE    @set_mode insert
and I get better results when clicking in a text area - before I would type and text would go in both the form and the command line!  


Web Jumps

# Web searching binds
@cbind  ,gg<Google:>_             = uri http://www.google.com/search?q=\@<encodeURIComponent(%r)>\@
@cbind  ,ddg<DuckDuckGo:>_    = uri http://duckduckgo.com/?q=%s
@cbind  ,wiki<Wikipedia:>_       = uri http://en.wikipedia.org/w/index.php?title=Special:Search&search=\@<encodeURIComponent(%r)>\@&go=Go
@cbind ,yt<Youtube:>_             = set uri = http://www.youtube.com/results?search_type=&search_query=%s&ag=f
@cbind ,gi<Google Image:>_     = uri http://www.google.com/search?tbm=isch&as_q=\@<encodeURIComponent(%r)>\@

#Hard-bound links
@cbind  gh  = uri http://www.uzbl.org

( the \ key doesn't seem to work)
Note: there is ibind that allows function in input mode, cbind for command mode, and ebind which is global


Bookmarks
the bookmark file is in ~/.local/share/uzbl, which you can edit by hand, but it mustn't have any blank lines.
The default bookmark open url script searches both the URL and tag, so ideally two bookmark open methods would be nice.
You could always make a html page of your bookmarks.


Context menus

# Default context menu
menu_add New Tab (gw)            = event REQ_NEW_WINDOW
menu_add Clone Tab (c)             = event REQ_NEW_WINDOW \@uri
menu_add Tab from Primary X ('p) = sh 'echo "event REQ_NEW_WINDOW $(xsel -o)" > "$UZBL_FIFO"'
menu_add Gmail                         = set uri = http://gmail.com
menu_add Go Uzbl                     = set uri = http://uzbl.org
menu_add Copy Tab Uri              = sh 'echo -n "$UZBL_URI" | xsel'
menu_separator separator_1
menu_add Close Tab                    = exit

# Link context menu

menu_link_add Open in New Tab   = event NEW_BG_TAB_NEXT \@SELECTED_URI



Caching webpages with Polipo

Uzbl has no caching on its own, adhering to UNIX principle where each app should only do its own job -  caching therefore is another app's job.  And caching is definitely required, so that things are speedy.  So here comes Polipo..
https://wiki.archlinux.org/index.php/Polipo
http://www.pps.univ-paris-diderot.fr/~jch/software/polipo/

apt install polipo

add to autostart
polipo &

mkdir ~/.polipo-cache
sudo cp /etc/polipo/config /etc/polipo/config.orig
sudo nano /etc/polipo/config
edit line:
diskCacheRoot = "~/.polipo-cache/"
[might get too big to be put in home! separate partition?]
Note, if you copy polipo config file to home dir, you need to call it on start, like this, polipo -c ~/.polipo.conf

if you stick with the /var/cache/polipo default cache location, then follow the archwiki page re how to make a polipo user

restart polipo..
sudo /etc/init.d/polipo restart or service polipo restart

add a line to uzbl config
set proxy_url = http://127.0.0.1:8123

problem: can't open CUPS web interface on localhost:631


Daemonise
to have polipo work in the background
add to the config file
logFile = "~/.polipo.log"
logLevel =    (see here for possible values)
and make the log file
touch ~/.polipo.log

or add this so that Polipo bypasses the log file and outputs to a terminal (if started there)
logFile = ""
logSyslog = false


Purging the polipo cache 
as polipo never removes a file from the cache, it installs a script in /etc/cron.daily which will tidy it up.
very useful info here http://go2linux.garron.me/....


Uzbl scripts

http://www.uzbl.org/wiki/scripts

Here's where a lot of extension can be made to the operability of the browser.
I'm only just at this stage.... and trying to figure out these scripts.  To test them run uzbl from a terminal and see what errors are turned out.
(happy face if they work for me)


 script I've tried  dependencies  works yet?  score
show keybindings show_keybindings.sh    :(  
keyword-bookmarks      
bookmark_with_tags_for_folders      
insert_bookmark.sh      
clean up the history from duplicate sites clean_history      
send open tabs to a queue to open them later on article_queue.py      
undo closed tab undo_tabbed   socat  froze the desktop :(  
lich downloader lich-download.sh       :)  
download destination and progress dl-progress-zenity      
download progress in the status bar dl-progress-statusbar      
download yt videos youtube-dl  youtube-dl ratpoison    
disable flash and play video in mplayer ytvp      

      

Troubleshoot Scripts
I had a problem getting scripts in my home config dir to work - which was probably my XDG_CONFIG_HOME not being set.

Uzbl sets some bind code at the start:
set data_home   = @(echo $XDG_DATA_HOME)@
set cache_home  = @(echo $XDG_CACHE_HOME)@
set config_home = @(echo $XDG_CONFIG_HOME)@

so you need these variable to be set if you are going to use them -system-wide in /etc/profiles, add these lines
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"

or perhaps in ~/.bashrc for per user

or else edit the uzbl config file to read echo $HOME/.local and echo $HOME/.config



Here's one I made!
It will add the URL of a link to the temporary bookmark list - need xsel (or change to xclip) - problem is uzbl doesn't clear the list on exit!
cd ~/.config/uzbl/scripts/ && geany insert_temp_link.sh

#!/bin/sh

. "$UZBL_UTIL_DIR/uzbl-dir.sh"

>> "$UZBL_TEMPS_FILE" || exit 1

echo "`xsel` $UZBL_TITLE" >> "$UZBL_TEMPS_FILE"

sudo +x insert_temp_link.sh

in uzbl config, Link context menu
menu_link_add Temp Bookmark = chain 'sh "echo -n "$1" | xsel" "\@SELECTED_URI"' 'spawn @scripts_dir/insert_temp_link.sh'

make another, flush_temp.sh, to flush the temp file when you need to,
#!/bin/bash

touch ~/.local/share/uzbl/newtemp
mv -f ~/.local/share/uzbl/newtemp ~/.local/share/uzbl/temps

and bind it like this
@cbind  d4 = spawn @scripts_dir/flush_temp.sh


Masquerade
you set the useragent so that some problem websites might work properly
eg
set useragent       = Mozilla/5.0 (X11; Linux x86_64; rv:2.0b9pre) Chrome/32.0.1667.0
pages rendered with very little style

set useragent       = Uzbl (Webkit 1.3)  (X11; Linux x86_64)
rendered properly

set useragent       = Mozilla/5.0 (X11; Linux x86_64; rv:2.0b9pre) Gecko/20130328 Firefox/22.0
runs nice too (latest Firefox version)

http://www.useragentstring.com/

Home | Content | Site Map | TOP