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.
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 π
Thanks, once I learn this language, I’ll get back to ya. π π
LOL, me too!
Happy Thanks Day Chris and to all who observe this holiday. π
I understand only a little of it but your joy of creating and that it will be useful for
many is coming through. Great, Geir!
Sounds terrific Geir! Translates to us being really privileged now? π
No chance to work in Bletchley Park ever π And don’t want to solve Enigma machine either! π
Ah yes! i was unable to get this to work in luakit.
It so great that you made a working system for uzbl.
Thanks a ton
You’re welcome βΊ