Slightly more uzbl

To make uzbl even more usable, I have added a download viewer script that is easy to configure and maintain. The purpose was to get uzbl to launch the appropriate viewer program when a file is downloaded from the net (like launching mplayer for a downloaded movie or zathura for viewing a downloaded pdf file). Other browsers do this as default, but as there is hardly anything default about uzbl (that is the whole point, really), one is left with the task of finding or creating the best add-ons even for viewing downloaded files. No add-on that I could find did the trick, and so I made one.

uzbl-logo

It wasn’t easy to figure out exactly how to hook a script into uzbl that fires upon a completed download. But with some pointers from people at the uzbl IRC channel, it was very easy to make it work.

Here’s what you do on a Linux system.

Add to your uzbl config file:

@on_event DOWNLOAD_COMPLETE spawn @scripts_dir/downloadviewer.sh %s

Then create the script “downloadviewer.sh” and place it in the scripts folder (on my system, that would be “/usr/share/uzbl/examples/data/scripts/”). Do a “chmod 755” on the file to make it executable. The script would contain something like this:

#!/bin/sh
case "$1" in
*.pdf*) zathura "$1" & ;;
*.jpg*|*.png*|*.jpeg*) feh "$1" & ;;
*.txt*|*README*|*.pl*|*.sh*|*.py*|*.hs*|*.hl*) urxvt -e vim "$1" & ;;
*.mov*|*.avi*|*.mpeg*|*.mpg*|*.flv*|*.wmv*|*.mp4*) mplayer "$1" & ;;
esac

Edit to accommodate for your choice of viewers and file types to view.

Additionally, to set the “download directory” for uzbl, edit the file “/usr/share/uzbl/examples/data/scripts/util/uzbl-dir.sh” and change the line starting with “UZBL_DOWNLOAD_DIR=” to what you like.

hth πŸ™‚

8 thoughts on “Slightly more uzbl

  1. Thanks, once I learn this language, I’ll get back to ya. πŸ™‚ πŸ™‚

  2. Sounds terrific Geir! Translates to us being really privileged now? πŸ™‚

Have your say

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s