uzbl and uzbl_tabbed.py: a browser that adheres to the unix philosophy

uzbl-logo.png

Like Vimperator for Firefox?  Want something a bit smaller? Easier to config from plain text files? Well meet Uzbl. Uzbl follows the UNIX philosophy – “Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.”

  • very minimal graphical interface. You only see what you need
  • what is not browsing, is not in uzbl. Things like url changing, loading/saving of bookmarks, saving history, downloads, … are handled through external scripts that you write
  • controllable through various means such as fifo and socket files, stdin, keyboard and more
  • advanced, customizable keyboard interface with support for modes, modkeys, multichars, variables (keywords) etc. (eg you can tweak the interface to be vim-like, emacs-like or any-other-program-like)
  • focus on plaintext storage for your data and configs in simple, parseable formats Uzbl keeps it simple, and puts you in charge.
  • Uzbl is under heavy development and should be considered alpha. See the Get uzbl page

Now while this all good and dandy, even with a tiling window manager, I find most WMs bad at managing many open web pages and find that more suitable for tabs within the browser, fortunate others do too and have written uzbl_tabbed.py.

This python application is a shell that is able to open and contain multiple uzbl instances in the one window using a gtk.Notebook widget essentially giving uzbl tabbing support. The parent application (uzbl_tabbed.py) uses a FIFO socket to receive commands from child uzbl instances to execute various functions in the parent application like creating a new tab, opening a tab from the clipboard, going to the next tab, closeing tab number 5, etc in the same way you normally control uzbl through its FIFO socket. There is nothing stopping you from sending commands to uzbl_tabbed.py’s socket and performing those same actions yourself either manually or automatically.

Upon start-up the uzbl_tabbed.py script reads the users uzbl config file (found at $XDG_CONFIG_HOME/uzbl/config) for any commands it is able to inherit and or load that relate specifically to uzbl_tabbed.py. After spawning a uzbl instance the parent communicates to its new child uzbl instance through its socket the bind commands that (you are able to define/change either in the application itself or in your uzbl config file) give you the ability to control uzbl_tabbed.py as you would any other external script. Remembering that uzbl_tabbed.py doesn’t listen or catch ANY keys pressed by the user but rather relies entirely from commands it binds to each child to navigate to the next tab, open new tabs, close tabs, etc.

Screenshot:

click for larger

click for larger

Basic Uzbl Usage:

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 available in the AUR in both stable and experimental flavors as uzbl-git and uzbl-experimental-git. 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 default config files 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.

With the default 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.

Below is a few of the keybindings defined in ~/config/uzbl/config, which you are free to go and change

Page Navigation

j         = scroll up
k         = scroll down
h         = scroll left
l         = scroll right
<<        = beginning
>>        = end
b         = back
m         = forward
S         = stop
r         = reload

Zooming
+         = zoom_in
-         = zoom_out
T         = toggle_zoom_type
1         = sh “echo set zoom_level = 1.0 > $4″
2         = sh “echo set zoom_level = 2.0 > $4″

Searching
/*        = search %s
?*        = search_reverse %s
gg <term> = search term in google

Inserting Text
i         = toggle_insert_mode   (Esc works to go back to command mode much like vim)

Bookmarks and History
B         = insert bookmark (bookmarks are saved in ~/.local/share/uzbl/bookmarks
U      = load url from history via dmenu
u         = load url from bookmarks via dmenu

Managing URLs in the clipboard

yurl      = uses a script to yank the url of the current page you’re at into the system clipboard
ytitle    = uses a script to yank the title of the current page you’re at into the system clipboard
y2url     = sh ‘echo -n $6 | xclip’ (does the same as yurl but without needing a script, I found this works best in urzl_tabbed.py over the other 2 currently)
p         = go the page from primary selection (if there’s a url in the clipboard p will take the page there)
‘p        = start a new uzbl instance from the page in primary selection

Exit
ZZ        = exit

Note: there is more defined in the ~/.config/uzbl/config file, you may want to take a look.

Basic uzbl_tabbed.py Usage:

First thing fist I downloaded the uzbl_tabbed.py script into by ~/bin directory (which is in my PATH).  You can download it here:

Stable

Experimental

Dependencies

Required

  • python 2.5-2.6 (May work on 2.4 but un-tested on that version)
  • pygtk >= 2.0

Optional

  • xclip – required if you wish to use the open new tab from clipboard command.
  • simplejson – required if you chose to enable JSON session saving/loading.

I keep mine in my path to easily call from gmrun or dmenu (depending on whether I’m in wmii or opebox). You might to assign a keybinding to open it if you wish.

Here’s how to use it:

gn        = new tab
gY        = new tab from url in clipboard
go _      = new tab from url typed
gC        = closes a tab
gt      = go to next tab
gT        = go to previous tab
gi _      = go to tab # specified
g<        = go to first tab
g>        = go to last tab
gQ        = close all tabs and start with a new tab
gZ        = close application

Currently this is the only command line option supported:

uzbl_tabbed.py -n, --no-session    ignore session saving or loading.

All other command line arguments are interpreted as uris to launch in new tabs. If sessions are enabled they will load after the restored session tabs.

Example:

./uzbl_tabbed.py -n http://google.com/ http://uzbl.org/ http://reddit.com/

Will open 3 new tabs pointing to the locations specified and ignore session saving/loading.

./uzbl_tabbed.py http://uzbl.org/

Will open a single tab on-top of the loaded session tabs.

./uzbl_tabbed.py -n

Will open a single tab pointing to your homepage and all session saving/loading will be ignored.

Consistency with Dmenu

I keep a file on my system at ~/.dmenurc which 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.
(this was taken from brisbin’s page on the matter).   I keep a file on my system at ~/.dmenurc which 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.

Open links from urxvt in uzbl

Note, this will open links in a new uzbl window, not a uzbl_tabbed.py tab.

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 file.

Sources:

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

http://pbrisbin.com:8080/uzbl.html

http://www.uzbl.org/

http://bbs.archlinux.org/viewtopic.php?id=70700&p=1

No Posts Found

Comments are closed.