Of Bookmarks, Tags, and Browsers

I recently acknowledged the fact that I had 70 tabs open in Chrome on my Desktop and 110 tabs open on my mobile firefox browser. Even using tab-suspend plugins like described here </blog/2017-04-06/taming-chrome-control-tabs-memory-and-free-space-for-your-work/> did not hide the fact that I was starting to create quite a browser mess here. Being sometimes kind of old-school, I thought: great, let's tidy all up and sort them into bookmarks. However, open tabs have some kind of to-do status for me and I didn't want to lose this to-do idea. So I could not just file them away in folders, but I needed a tagging function to sort one and the same tag into several categories. Unfortunately using bookmarks is deemed kind of old-fashioned today: Why bother remembering if Google can not find it easily anyway? Therefore old folder structures exist, but the ideas of tags and categories only attracts very few people and therefore is also not well supported by the open source community.

The desktop version of Firefox though, does have a nice tagging feature. Chrome does not (apart from some less than well supported extensions). Therefore, I decided to export all my tabs and switch - after a long time using Chrome - back to Firefox again. It took me a couple of ours to tag them all, but soon I had easy access to them on the Desktop. I even activated Firefox Sync and wanted to start using all my to-do-bookmarks on the road. How stupid of me? I actually assumed bookmarks on Firefox for Desktop would work similar to bookmarks on Firefox on Mobile - stupid me, these are two very different pieces of Software! OK, no way to access and search my tags on Firefox Mobile.

What now? Another look at extensions. While trying some extensions, I had to learn that Firefox is just moving on (again and again) to a new extension (web extension) system and therefore soon all of the plugins will not work anymore - ah great, that was actually why I did like Firefox. Being very annoyed, I started focusing on Chrome plugins again and started looking at options how to extract all my bookmarks and tags back out of Firefox. Fortunately, Firefox has a json-export option, which I gladly used. Now I had all my bookmarks and tags in a format, I could read and read out with some little Python-magic. However, I did not like the idea to re-import them into proprietory Chrome and risking losing them again - so I looked at other options to manage bookmarks. I stumbled on a really nice project: https://github.com/jarun/Buku

A command line bookmark manager which even has several extensions - that sounded interesting. As excited as this person here, I installed it and wrote a small script to feed my json bookmarks into buku:

import json
import subprocess

def traverse(bm):
    ks=bm.keys()
    if "uri" in ks:
        title=""
        uri=bm["uri"]
        tags=""
        if "title" in ks:
            title=bm["title"]
        else:
            keys=bm["keys"]
        if "tags" in ks:
            tags=bm["tags"]
        print("buku -a \"{}\" --title {} {}".format(uri,title,tags))
        subprocess.call(["buku","-a",uri,"--title",title,"--tag",tags])
    if "children" in ks:
        for b in bm["children"]:
            traverse(b)

bm = json.load(open("bookmarks.json"))
traverse(bm)

That was not that hard.

Now, I just needed something to easily search and create these bookmarks. For searching, I installed oil: https://github.com/AndreiUlmeyda/oil And for editing, I connected this little script to Super-Shift-B:

#!/bin/bash
source "$HOME/.ulno-environment"
sleep 0.1
xdotool key --clearmodifiers ctrl+l
sleep 0.1
xdotool key --clearmodifiers ctrl+c
xfce4-terminal -x buku -a "$(xsel)" -w editor
sleep 0.4
xdotool key -clearmodifiers Down Down Down Down Down Down Down

Replace the terminal with a terminal of your choice (not gnome-terminal as it doesn't behave like a regular unix program). When in a browser, it focuses on the url-bar (ctrl-l), copies the url, and then opens it with buku in a terminal.

Great, I am finally back and can edit and probably even synchronize my bookmarks, both on my Desktop and on my phone. Furthermore, I can easily extend the mechanism and eventually also add a snapshot function.

Comments