How to Create a Custom Launcher in Unity on Ubuntu 11.10

One of the first things I always have to do after a fresh install of the latest Ubuntu (or whatever distro is striking my fancy at the time) is create some custom launchers for applications like Eclipse.

Prior to Unity this was done quite easily by editing the menus. In Ubuntu 11.04 with Unity this was no longer an option, so you could right-click on your desktop and select “Create Launcher” and then move the new launcher to ~/.local/share/applications, or there was also a method of creating a .desktop file manually that did the trick.

In Ubuntu 11.10 the right-click menu option for “Create Launcher” was removed (you can read more about why here), so we’re really left with no easy way to create custom launchers. I consider myself a gearhead but even I didn’t care for the “just launch the binary from the terminal” suggestion by some people in the bug thread.

So in my semi-obsessive reading about all of this last night I came across a metion of a package called alacarte that brings back the classic menu editing functionality we knew and loved back in the pre-Unity days.

Just install it:

sudo apt-get install alacarte

Then run it (alacarte from a terminal, or just hit super and search for alacarte), and you’ve gone retro with your menu editing.

One of the 10,000 things I love about free sofware–if there’s an annoyance like this chances are someone else who’s annoyed will fix it, or you can always jump in and fix it yourself. Clearly this wasn’t something on which the Ubuntu developers were going to budge but the alacarte solution works extremely well.


Installing Cisco AnyConnect on 64-Bit Ubuntu 11.10

Every six months for the past few years I’ve been posting how to install Cisco AnyConnect on the latest 64-bit releases of Ubuntu and for a couple of cycles Linux Mint since I was using that as my primary OS for a while.

This time around it’s finally downright boring, which is a good thing. No more installing 32-bit libraries, creating symlinks to Firefox libraries, etc. etc. you just do the following:

  1. Hit your company’s VPN server in a browser and log in with your user name and passcode
  2. Click the AnyConnect link on the left
  3. Click “Start AnyConnect”
  4. This will attempt to install AnyConnect via your browser’s Java plugin. If this works, you’re done! If this doesn’t work (give it at least 60 seconds), read on.

In my case on the two machines on which I attempted this it didn’t work. The browser-based install just hung even though I verified I have Java installed and the browser plugin is working.

If you don’t have Java installed, however, the browser-based installation will detect that and give you a download link for the installer. So what I did was in Firefox I went to Edit -> Preferences -> Manage Add-Ons -> Plugins and I disabled the IcedTea-Web Plugin, which is the Java plugin that Firefox ships with.

I then restarted Firefox and repeated the steps above, only this time on step 4 it detected I didn’t have Java installed and provided a link to the 64-bit installer. Download that file (, chmod +x it, run it, and you’re done.

I’m a little disappointed I didn’t have to the usual dance on this, but it finally just works.

Fix for Empathy AOL IM Login Issues on Ubuntu 11.10

I’ve installed Ubuntu 11.10 on my two System76 laptops (I have a Lemur and a Serval), and on both machines I noticed while I was configuring Empathy it wouldn’t log into AOL IM successfully.

After verifying I wasn’t fat-fingering my password I did some poking around and came across a post-install to-do list for Ubuntu 11.10 that fixed the issue for me. You can of course pick and choose which plugins to install, but I suspect just using the latest version did the trick. There were some on-again off-again bugs related to AIM and ICQ logins during 11.10 development.

Full details are in the linked blog post above, but here’s the basics:

sudo add-apt-repository ppa:telepathy/ppa
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install empathy

With the new version the AIM login issue immediately went away.


Manually Installing Java Plugin for Firefox on 64-Bit Ubuntu 11.10

Since I always forget how to do this I figured I’d blog it for my own purposes so I don’t have to sift through Google every time.

This assumes you have the JDK installed under /opt/java/jdk1.6.0_27 — adjust accordingly if you have things installed elsewhere or only have the JRE.

Open up a terminal and do this:

cd /usr/lib/mozilla/plugins
sudo ln -s /opt/java/jdk1.6.0_27/jre/lib/amd64/

Then restart Firefox if it’s running.

Now to look into doing this for Chrome …

Revisiting Retrieving Documents Between Two Dates From CouchDB

In a previous post I outlined how I was retrieving documents from CouchDB with a start date property less than the current date, and and end date property greater than the current date. To summarize, in my CouchDB view I created some date/time strings in JavaScript and only emitted documents in the view that met the date criteria.

My previous post got referenced in the CouchBase newsletter, and I’m really glad it did because while I came up with what I thought was a clever solution it was also wrong. (D’OH!)

The issue I didn’t consider that some kind commenters on the previous post pointed out is that my approach creates side effects because I’m emitting documents in the view based on information that isn’t in the document itself. Specifically since I’m using the current system date/time when the view is created, the documents included in the view will be ones for which the criteria is valid when the view is created.

What this means is that although views get updated with current data as data within documents changes, since the entire view isn’t generated each time the criteria used to determine whether or not documents are included in the view is a fixed point in time. To put it another way, my current system date/time that was current when the view was first created essentially becomes hard-coded once the view is created, which isn’t at all what I needed. This causes issues if the start and end date properties in the documents change after they’ve been added to the view because the view only checked to see if the date criteria was met at the time the document was added to the view.

There are some great suggestions in the comments on my previous post for including data in the document itself that would allow only valid documents to be pulled right from Couch, and you’ll certainly want to check those out if you’re dealing with a ton of data. The solution I’m using will not be ideal for massive datasets but since that isn’t the situation I’m in with this data, I wanted to share the solution I came up with in case this works for other people.

To describe my documents again, I have documents that need to be displayed on a web page if their start date/time property is less than the current date/time and if their end date/time property is greater than the current date/time.

Since the valid ranges go in opposite directions for those fields, I didn’t see a way to do something like have an array key that included both the start and end dates that would allow me to get only the documents I want back from Couch. But what I can do is use a single document property as a key in Couch and get close to what I want, and then I can pare the documents down further in the application code.

In my case the end date is a more strong limiting criteria since over time there will be a large number of documents with both start and end dates in the past, but documents with end dates >= the current date will be much fewer in number (only a handful in the case of this specific data).

The first step to fix my issue was to rewrite my view to eliminate the date/time check in JavaScript since that’s the cause of the unwanted side effect, and emit documents using the end date/time property as the key. I have some other criteria as well (checking type and a couple of other fields to pull valid documents for this particular display), but the basic view is now very simple:

function(doc) {
  emit(doc.dtEnd, doc);

With the end date/time as the key, on the application side I can simply use the current date/time as my start key when I call this view, and that gives me all documents with a valid end date/time (>= current date/time).

At this point I may still have documents that shouldn’t be displayed based on the start date/time, however, since when people enter data into this application they can schedule things for future display (i.e. both start and end date/time are in the future). But, again since I’m not dealing with a huge amount of data once I limit by the end date/time, it’s simply a matter of looping over the documents I get back from Couch and checking for a valid start date/time (<= current date/time) and only displaying those documents.

The issue my original view code created makes total sense now, so thanks to the commenters on my previous post who pointed out the fatal flaw in my approach. Nothing like doing something wrong as a means of learning.

Retrieving Documents Between Two Dates From CouchDB

I’m working on converting yet another application from using SQL Server to using CouchDB, and this morning I’m working with some announcement documents that are displayed based on their start and end date. There are numerous ways to approach this problem but I thought I’d share what I came up with in case this solution helps others, and also to see if there’s maybe another approach I didn’t consider.

First, since there is no date datatype in JSON, we’ve standardized (for better or worse) on storing dates as a string with the format “YYYY/MM/DD HH:MM:SS”, e.g. “2011/08/27 09:22:36”, so date and time separated by a space, always with leading zeros for single digits, and always using a 24-hour clock. This allows date/time strings to sort properly when they’re used as keys, it’s easy to split the string using the space if you need either just the date or just the time, and since this application is for my day job the time will always be in Eastern US time so we decided not to care about the timezone offset.

In the data I imported from SQL Server there is a dtStart and a dtEnd field so I just converted the SQL Server dates to our preferred CouchDB date format as I imported the data into CouchDB. So far so good.

The next step was to pull these documents from CouchDB based on their dtStart and dtEnd fields, and this is probably obvious but just so it’s clear, I need to pull all documents of this type where dtStart <= now, and dtEnd >= now.

As I started creating my view in CouchDB for this, my first thought was to pull all the documents using an array including dtStart and dtEnd as the key. That way when I call the view I could, in theory, use a start and end key to get me the documents in the range of dates that I want.

That approach seems reasonable at first, but when you start trying to put it into practice things get weird rather quickly. This is because what you wind up needing is documents in which the first element of the key array is less than the current date, while the second element of the key array is greater than the current date. Maybe this is just “Saturday morning brain” on my part, but I didn’t see a way to include both the start and end date in the key and get where I needed to go.

My next thought was to use only the end date as the key. This gets me a bit closer to what I need since I can at least use a start key to only get documents with an end date >= now, but I’m still faced with having to check the start date at the application level to see if the document is supposed to be displayed.

I’m sure there’s some clever way to handle this situation with keys, and part of my reason for posting this is to see how others would approach this, but I messed around with keys for a while and didn’t seem to be getting anywhere so I decided to take a different approach.

One of the great things about CouchDB is the fact that you have the full power of JavaScript available in your views. Although JSON doesn’t know what a date is, JavaScript certainly does, so I decided that since I needed to pull things based on a specific date range across two fields in my documents the best place to handle that was in the view code itself.

Here’s what I came up with for my map function:

var d = new Date();
var curYear = d.getFullYear();
var curMonth = (d.getMonth() + 1).toString();
var curDate = d.getDate().toString();
var curHours = d.getHours().toString();
var curMinutes = d.getMinutes().toString();
var curSeconds = d.getSeconds().toString();

if (curMonth.length == 1) {
  curMonth = '0' + curMonth;

if (curDate.length == 1) {
  curDate = '0' + curDate;

if (curHours.length == 1) {
  curHours = '0' + curHours;

if (curMinutes.length == 1) {
  curMinutes = '0' + curMinutes;

if (curSeconds.length == 1) {
  curSeconds = '0' + curSeconds;

var dateString = curYear + '/' + curMonth + '/' + curDate + ' ' +
    curHours + ':' + curMinutes + ':' + curSeconds;

if (doc.type == 'announcement' &&
    doc.dtStart <= dateString &&
    doc.dtEnd >= dateString) {
      emit(doc.dtEnd, doc);

Now of course you could argue this would all be simpler if I stored the dtStart and dtEnd fields in my documents as milliseconds, because then I could just get the millisecond value of the current date and do a quick numeric comparison instead of all the string formatting and concatenation, and from that perspective you’d be absolutely right. One of the many things I love about CouchDB, however, is the ability to jump into Futon and more directly and easily interact with my data, so keeping the dates human readable is kind of nice. Now I could store both a string and the millisecond value I suppose, but since this did the trick I decided to leave well enough alone.

I’m very curious to hear how others might solve this problem. “You’re doing it wrong” information would be quite welcome. 😉

Fixing BackInTime Snapshot Failures

Although it's really simple to write your own rsync script to do backups on GNU/Linux, I'm a big fan of BackInTime because it's a more sophisticated, snapshot-oriented backup solution (very similar to Apple's Time Machine) as opposed to the blind copy and sync that you'd typically wind up with using a one-line rsync script.

The issue is that even when running BackInTime as root there are some directories, symlinks, etc. that it can't copy or certain operations it can't perform, so you wind up with failed snapshot errors. In the past I never really dug into them and just went back to using an rsync script to sync to my Amahi server, but today I decided to spend a bit of time working through the errors since they were exacerbated a bit due to my home directory being encrypted on my new System76 Lemur UltraThin.

What makes this process easy is that BackInTime keeps excellent logs of where it's failing, and as opposed to taking the time to investigate why each of these operations was failing, I just added a few patterns and directories to my exclude list and my snapshots are succeeding now.

The specifics in your situation may vary, but in my case I added the following to be excluded:
  • *gvfs*
  • [a few symlinks that pointed to directories in my home directory itself]
  • /home/mwoodward/.config/chromium
  • /home/.ecryptfs/mwoodward/.Private
  • /home/mwoodward/.Private
  • /home/mwoodward/.gconf
  • /home/mwoodward/.pulse
With those in the exclude list the snapshots are clean and I'm happily backing things up with BackInTime again. What I need to do next is verify that these exclusions aren't causing any issues, but since all I really need is the bulk of the files in my home directory to be backed up based on the bit of poking around I did it seems to be working fine.