Dumb Bookmarks from Uzbl

dumb is a minimalist, command line based, bookmark manager that I'm writing; it is meant to follow the *nix approach and thus should work quite well together with the uzbl browser.

This HOWTO assumes that you have one or more dumb collections in ~/.dumb/collections and that they are valid git repositories, but can be easily adapted to other locations and DVCSs.

Adding Bookmarks

In the uzbl config file (usually ~/.config/uzbl/config) add the following line:

@cbind  Ba  = spawn /usr/local/bin/uzbl-add-bookmark.sh

note that some default configuration file already binds @scripts_dir/insert_bookmark.sh to the B key: you may want to comment out or delete the line.

You will then need to create the /usr/local/bin/uzbl-add-bookmark.sh script; you can choose between a quick-and-dirty one that simply adds a minimal bookmark, or a more refined one that uses zenity to ask some questions and allow for more data.

If you have no write access to /usr/local/bin you can of course use ${HOME}/bin or some other location.

Quick and Dirty

A minimalist script that simly adds an url and the title is:

#!/bin/sh

title=$(echo "$7" | sed 's/\t/    /')
url=$6

cd ~/.dumb/collections/my_bookmarks
git add `dumb-add -v -t "$title" "$url" `
git commit -m "$url"

This assumes that bookmarks should simply be added to the collection in ~/.dumb/collections/my_bookmarks.

Zenity Based

This allows to select a collection, add tags and a comment to the bookmark, but requres dumb > 0.2 (i.e. currently just git):

#!/bin/sh

DUMB_COLLECTIONS=~/.dumb/collections

TITLE=$(echo "$7" | sed 's/\t/    /')
URL=\'$6\'

if [ x'' != x"$TITLE" ]
then
    TITLE="-t '$TITLE'"
fi

COLL=$(ls $DUMB_COLLECTIONS | zenity --list --column="Collection")

if [ x'' == x$COLL ]
then
    COLL=my_bookmarks
fi

cd $DUMB_COLLECTIONS/$COLL


KEYWORDS=$(dumb-list-keywords | zenity --list --editable --multiple --separator=' ' --column='Keywords')

if [ x'' != x"$KEYWORDS" ]
then
    KEYWORDS="-k '$KEYWORDS'"
fi

COMMENT=$(zenity --entry --text="Comment:")

if [ x'' != x"$COMMENT" ]
then
    COMMENT="-c '$COMMENT'"
fi

git add `dumb-add -v "$TITLE" "$KEYWORDS" "$COMMENT" "$URL" `
git commit -m "$URL"
Send a comment: unless requested otherwise I may add it, or some extract, to this page.

Return to Top