Categories
Computers Programming Python

uzbl and dmenu

I’ve been playing around with uzbl again and decided it was high time I tried out dmenu. What I’d read made it sound pretty slick, I was just leery of having to learn how to work with another application. Thankfully, dmenu is extremely easy to use. It isn’t available as a deb package, but the source is readily available. I built it with the vertical patch.

As practice I figured I’d rewrite one of the stock uzbl scripts as a python script. I chose the load_url_from_bookmarks.sh script since it was pretty easy for me to decipher. That’s not sayin’ much since my bash scripting foo is, well- ‘miserable’ is probably the right word.

The exercise proved valuable for a couple of reasons.

It was a good exercise for 2 reasons. First, it’s much longer than the bash equivalent. So knowing a little bash scripting and some awk or sed is a pretty valuable tool. I may put a little more effort into that sort of thing. Of course, I think the python script is more readable, but without knowing bash scripting I can’t really say that in any authoritative sense. Also, working with shell commands is much simpler from a bash script than from python.

You’re rolling your eyes “Well, DUHHH!”

Guess I can’t blame you. In my defense, I knew bash scripting would make that sort of thing easy. I just thought that it would be simpler in python. Not that it was difficult. But it’s a lot easier to read the bash script and understand the command stuff than look at the python script and understand the Popen objects.

The second reason it was a good exercise it because I improved upon the stock implementation. Namely, I’ve added labels to the url’s in the file. The labels are what is seen in dmenu. Then the url that is paired with it is sent to uzbl using socat. I think this is a little nicer presentation wise.

The line format for the bookmark file should be as follows:

"label"  "url"

The space between can be arbitrarily long.

The script is here.

I haven’t worked up a script to add bookmarks to the file. I’ll save that for another day.

Leave a Reply

Your email address will not be published. Required fields are marked *