/ root / pages / uzbl.html

You're using an old link! - Thankfully, you no longer need to specify a nonstandard port (8080) to access my site. You could've used the more standard: http://pbrisbin.com/pages/uzbl.html.

Uzbl


Uzbl is the pet project of an Arch Linux release engineer. It's designed to be a browser that conforms to the Unix philosophy: Do one thing, do it well. Work well with other programs. Communicate through the most common form of communication, text.

The idea is that uzbl simply browses webpages. It can be controlled via a fifo or socket, and the user is required to extend the browser with custom scripts to handle cookies, history, bookmarks, etc.

What it looks like

It's not much to look at (compliment!), but here's lookin' at uzbl lookin' at google:

Uzbl 
        Shot

Installation

Uzbl has been ported to many platforms. Information on that can be found at their site via the above link. As for Arch, uzbl is in the AUR in both stable and experimental flavors (uzbl-git and uzbl-experimental-git respectively). Use whatever AUR method you choose to get whichever branch you want on your system.

Once installed, you'll want to get the default configuration going. Uzbl ships with a sample config and some handy scripts in /usr/share/uzbl/examples (make sure you've got dmenu and zenity installed to make use of the history and bookmark scripts).

  cp -r /usr/share/uzbl/examples/config/uzbl ~/.config/
  cp -r /usr/share/uzbl/examples/data/uzbl ~/.local/share/

Be sure to mkdir ~/.config and ~/.local/share beforehand if they don't exist.

Usage

With the sample config, Uzbl feels kind of vim-like: h,j,k,l to move around, i to insert text, etc. o <url> will open a new url. u and U will present your bookmarks and history for selection via dmenu. B to add a bookmark through zenity.

From here, the world is your oyster. Take a look at the stock config at ~/.config/uzbl/config and go hack!

My contributions

I wrote a little download.sh script that will display a dzen bar along the bottom of the uzbl window just above the status bar when you download a link. It'll show progress, time remaining, and a gdbar progress bar. You can grab that here. It has its bugs, but I like it nonetheless.

I also now have another download script that does pretty much the same thing using zenity. It's designed to be used with jumanji, another great light browser but could be easily modified to work with uzbl as well.

My recommendations

I keep a file on my system at ~/.dmenurc which simply defines a variable $DMENU like this:

DMENU='dmenu -i -fn xft:Verdana-8 -r -x 0 -y 15 -nb #303030 -nf #909090 -sb #909090 -sf #303030'

Then, in the four or five scripts I have that call dmenu, I do something like this:

#!/bin/bash

if [ -f $HOME/.dmenurc ]; then
  . $HOME/.dmenurc
  else
  DMENU="dmenu -i"
fi

file=$XDG_DATA_HOME/uzbl/bookmarks
goto=`awk '{print $1}' $file | $DMENU`

Now, if ~/.dmenurc exists, that script will use those dmenu options; otherwise, it'll be the default (case insensitive) dmenu. The benefit here is that I can change one file to adjust the 'theme' of dmenu no matter where or how I call it.

I also use uzbl as my browser when clicking links out of urxvt. I do this because it opens immediately, and I often want to simply view the link and quit. This setup does take a little tweaking compared to the traditional firefox method. What you need is a small shell script to call uzbl with the right options, then call that script from your ~/.Xdefaults.

Save the following as uzbl_launch.sh and chmod +x it:

#!/bin/sh
uzbl --uri "$@" &

Then add the following to your .Xdefaults file

  URxvt*perl-ext-common: default,matcher
  URxvt*urlLauncher: uzbl_launch.sh
  URxvt*colorURL: #86a2be
  URxvt*matcher.button: 1

Make sure uzbl_launch.sh is in your $PATH, otherwise call it with /the/full/path/to/uzbl_launch.sh in your ~/.Xdefaults.

Update!

I've updated uzbl_launch.sh a bit with some new functionality. First I wanted to auto-handle the schemes as this was not done by earlier version of uzbl, basically if I pass anything://url then use it, otherwise add http:// automatically. I also wanted to copy vimperator's auto-google functionality. So while uzbl_launch.sh can be used outside of of uzbl to open links out of urxvt, I also bind it to :o and :n for open link and open link in new window from within uzbl. This way I can type :o something.com and it'll go, or :o some thing and it'll google 'some thing'.

This is all done by the following script (note that the live version in ./bin may differ):

#!/bin/bash
#
# all purpose url launcher for uzbl
#
# add to uzbl config:
#
#   @bind  :o_  spawn /path/to/this our %s
#   @bind  :n_  spawn /path/to/this new %s
#
# NOTE: doing it this way (:o_ vs :o _) lets us
#   hit :o<enter>; to just go home and :n<enter>; to
#   open a new window at our home page.  :o someurl
#   still works fine, but the mode is passed in as
#   $8, a space is passed as $9, and the url is
#   passed as $10 (shift; $9). this is accounted
#   for in the script, but if you use a different
#   binding you'll need to adjust this part.
#
# so:
#
#   our %s means open %s in this window
#   new %s means open %s in a new window
#
#   if %s isn't set, it'll be $home_url
#
#   if %s doesn't contain '://' then http:// will
#     be preprended to it
#
#   /path/to/this %s from CLI simply opens %s in a
#     new window
#
###

# set a 'home page' 
# used when no url is passed
home_url="http://www.google.com"

if [ $# -gt 2 ]; then # being called from uzbl
  shift 4; SOCK="$1"
  shift 3; MODE="$1"
  shift 2; URL="$@"
  else # being called outside uzbl
  MODE="new"
  URL="$@"
fi

# did we pass a url?
URL="${URL:-$home_url}"

case $URL in
  *://*) :                 ;; # use URL as is if protocol is in string
  *.*)   URL="http://$URL" ;; # assume it's a URL if a . is in the string
  *)     URL="http://www.google.com/search?q=${URL// /+}" ;; # otherwise search google
esac

# new window or our window
case $MODE in
  our) echo "uri $URL" | socat - unix-connect:$SOCK & ;;
  new) uzbl-browser -u "$URL" &                       ;;
esac

Update 2!

All of the above info is a bit out of date. I've revisited my uzbl setup and have some (hopefully) better ways of doing things. If you're interested, please checkout the updated info here.

Comments





pbrisbin dot com 2010