Quick QR Code Generation

QR Codes are a really easy way to share information between your desktop or laptop and a smartphone, which don’t have the privacy issues inherent in Google’s Chrome To Phone. The excellent FOSS Barcode Scanner app for Android makes scanning these codes and opening the scanned data a breeze. However, generating them on the desktop can be a bit of a pain. There are several websites, browser addons and APIs for generating these codes, but up until now I haven’t found anything really quick and easy.

That is until today, when I discovered the ‘qrencode’ utility. Qrencode does exactly what it says on the tin. It takes some text, encodes it as a QR Code and writes the result as a PNG file. It’s a simple command line tool, which opens up awesome scripting possibilities.

My use case is simply to send the URL of a web page that I’m viewing on my desktop to my phone, via QR Code. I found that qrencode was quite happy to write its output to stdout, which meant I could display the result directly using ImageMagick’s ‘display’ command, e.g:

$ qrencode http://blog.webworxshop.com -o - | display

You’ll notice that by default the QR Code is quite small. We can fix this by increasing the block size:

$ qrencode http://blog.webworxshop.com -s 10 -o - | display

Next, I wanted to automatically pull the text to encode from somewhere to save typing – the clipboard was an ideal candidate. Enter ‘xclip’. Xclip is a command line utility to read and write from/to the X system’s built in clipboard. I used bash’s backtick command substitution to grab text from the clipboard and encode it:

$ qrencode `xclip -o` -s 10 -o - | display

And there you have it, a simple one line command to generate and display a QR Code from the contents of the clipboard. I created a bash script containing the command and assigned it to a keyboard shortcut in Gnome (Ctrl-Shift-Q), so that sharing URLs to my phone is as simple as selecting the text in the location bar and hitting Ctrl-C followed by Ctrl-Shift-Q.

If you want to give this a try, you’ll need to install the utilities discussed, in Fedora these can be installed with:

$ sudo yum install qrencode xclip ImageMagick

Enjoy!

SwallowCatcher 0.1.1 Released

Download SwallowCatcher 0.1.1

Download SwallowCatcher 0.1.1

Today sees the release of the second version of SwallowCatcher, version 0.1.1. This version contains many enhancements and bugfixes over the previous version and should so be considered as the main stable release for the 0.1.x series. Further releases in this series will contain bugfixes, with new features being added to 0.2.x.

Obligatory release notes:

Features:

* Import Podcasts from OPML;
* Add Podcasts Via Barcode or URL;
* Open podcast:// and feed:// URLs directly in SwallowCatcher;
* Download Podcast feeds;
* List newly found Episodes;
* List Subscriptions and Episodes;
* Download Podcasts;
* Share via intent (and thence via email, mustard, etc.).
* Basic playback support.

Fixed Issues from Previous Version:

* New episodes screen issue;
* Can now add podcasts directly by feed URL;
* Added basic playback support;
* Prettier downloads list;
* Podcasts list remembers scroll position;
* Fixed text on the first run dialogues;
* Fixed OPML import from Google Reader;
* More robust feed/date parsing;
* Lots of general stability fixes;
* Much improved UI with more options, etc.

Known Issues:

* Downloads still aren’t pausable/resumable;
* I need some icons!

Future Plans:

The 0.1.x series will continue to address the remaining issues above and fix bugs.
The next main release (0.2.0) will include cover art and show notes support.

SwallowCatcher is still not in the Android Market so either download above or check out the project page and the gitorious page where you can download the source code. Feedback and bug reports can again be submitted via identi.ca, email or via the comments on this post. No Spam please (only ham and eggs).

Blogging and Development Haitus

People following me via identi.ca and via the site feed may have noticed that I’ve been a bit quiet lately. I won’t go into the details about what’s been going on (its all been good stuff though), but its safe to say I’ve been a bit busy. Anyway, I’m back (pretty much).

I’ve decided now to focus my spare time on SwallowCatcher development and poking around with cool technologies that I come across, with some write-ups here. This means that I’m ditching the Unofficial Python Module of the Week segment. This is really because I just can’t hack the schedule and don’t want to be tied down to blogging at specific times.

However, on the up side SwallowCatcher development will resume from today and I hope to have a new release soon. Of course the new release will be posted here as soon as it’s ready.

Also, apologies to anyone who came across my site in its eye-offending pink and grey glory. I’m not sure what happened there. I’m hoping that the site wasn’t hacked in my absence and I can’t find any other evidence of that, but its weird nonetheless.

Syncing: How can it be this difficult?

OK, prepare for a rant.

I’ve been looking at ways to sync data across multiple systems. Basically I’m looking for something that can sync contacts, calendars and tasks across multiple devices. Ideally, this would be between a couple of desktop systems and my Android phone (preferably with a web interface for the rare occasions I’m without either). I don’t need to sync email due to using IMAP and the excellent clients available for it nowadays (personally I use Thunderbird 3.1 and K9 Mail).

Now I bet you’re screaming at me: “Why don’t you just use Google Contacts/Calendar/Tasks?”. Well currently I am, but in my ongoing quest to replace as many of these things with Free Software implementations, I was wondering what else I could use. Basically, the answer is that there isn’t anything that satisfies my requirements. There are lots of solutions which will do part of this, but nothing that will do everything. Having said that, I’m not against putting multiple components together to make a system that suits me better – in fact this is probably the best way to go about it. Probably the best project I’ve looked into is Davical, which seems to have the calendaring down, but web interfaces and Android support are a problem.

I guess what I’m really wondering is why isnt’ there some nice web application I can install that does all of the above, has connectors for popular platforms (i.e. Thunderbird and Android) and is Open Source? I mean really? I don’t know why this isn’t solved yet! How difficult is it, compared to say web apps like WordPress or Drupal? (I’m kinda hoping that I’ve missed something like this and some helpful person will step out of the Internet woodwork and point me in the right direction).

Of course if I come up with a solution I’ll be happy to share it. If anyone has any tips, please comment below.

Unofficial Python Module of the Week #2: configobj

Welcome to our third instalment of interesting Python modules. Unfortunately I’m a bit late with this section this week – in fact its next week already! The fourth instalment should be along towards the end of the week thus catching me up.

Today we’re going to cover something which isn’t in the standard library, but is nonetheless very useful. The module is configobj which is used for reading from and writing to INI style configuration files files. A simple INI file is shown below:

item1 = value
item2 = value2

[ section1 ]
item1 = value

[[ subsection ]]
item1 = value

In the above we can see the simple use of items, values sections and subsection. Subsections can be nested down as far a you want, but I don’t think most applications will need many more than two or three levels.

Installation

As this module isn’t in the standard library, we need to install it. On most Linux distros it should be in the package repositories, for example on Fedora 14:

$ sudo yum install python-configobj

Windows and Mac users can install from PyPi by following the instructions on the homepage.

Basic Usage

Reading from a configuration file with configobj couldn’t really be any simpler:

import configobj
config = configob.ConfigObj(filename)
myoption = config['item1']
mysectionoption = config['section1']['item1']
mysubsectionoption = config['section1']['subsection']['item1']

Basically, all you need to do is open a ConfigObj object by passing it a filename, then you just read from it as if its a dictionary object. Sections and subsections appear as nested dictionaries. Writing to the file is just as simple:

import configobj
config = configob.ConfigObj(filename)
config['newoption'] = 'new stuff'
config.write()

No surprises here, you just write to it as if it were a dictionary. All you have to do it call the write() method when you’ve finished, in order to sync everything to disk.

That’s pretty much it for basic usage. There is much more you can do with configobj, including advanced stuff like validation of configuration files. Check out the documentation for more info.