Tag Archives: registry

A couple of handy OLPC XO Sugar utilities

Originally posted onĀ joviko-olpc.blogspot.com January 23, 2008.

I’ve recently been working on a few new Activities for the XO. As a result of this, I’ve discovered that there isn’t a complete set of utilities for dealing with Sugar’s internal tracking and record-keeping of Activities.

You can use the Journal Activity to install the “.xo” files for new Activities. You can use the Sugar Activity toolbar to “remove” an Activity. This removal is far from effective; it oftentimes does not actually delete the Activity’s files in /home/olpc/Activities, and just as often, it doesn’t remove Sugar’s internal record of the Activity.

You can also manually install Activities via the ‘sugar-install-bundle’ utility, which can be run from the command line in the Terminal Activity. However, if you’ve already installed and then removed an Activity, it is very likely that ‘sugar-install-bundle’ will crash, complaining that the Activity already is installed, since Sugar never deleted its internal record of the Activity. This can be very frustrating when you’re testing the installation of a new Activity, and need to remove and reinstall it multiple times.

I ended up poking around in ‘sugar-install-bundle’ (which is a Python script), and discovered that it calls some other Python modules in /usr/lib/python2.5/site-packages/sugar. These, for someone hoping to create an Activity, might be worth looking at, particularly the ones in the “activity” and “bundle” subdirectories. “…/activity/registry.py” is a particularly good one.

After all that poking, I saw the classes and functions needed to list all of the Activities that Sugar currently is aware of. These are stored in Sugar’s registry (a binary database similar in use to the registry under Windows). I also saw how to remove the entry for a specific Activity from the Sugar registry.

Each entry has a name (e.g. “Sonata”), an icon, a “bundle ID” (“com.ywwg.Sonata”), an installation path (“/home/olpc/Activities/sonata.activity”), a command to launch the Activity (“sugar-activity SonataActivity.SonataActivity”), and a show-launcher indicator.

The Activities appear to be accessed and referred to by their installation paths, rather than their names or bundle IDs (which is a bit surprising to me, but using the path as the primary access key may allow both the names and IDs to be non-unique).

I’ve created a couple of handy utilities, ‘sugar-list-bundles’ and ‘sugar-forget-bundle’. Both are short Python scripts, and can be run from the Terminal Activity’s command line. They can be downloaded in a “.zip” file fromĀ here.

‘sugar-list-bundles’ doesn’t take any arguments. It just dumps out the info on all the Activities currently listed in the Sugar registry. It lists the name, ID, path, and command for each Activity. To run it from the command line (assuming you’ve unzipped the utilities into the current directory):


‘sugar-forget-bundle’ takes one argument, the name of an Activity. This name must exactly match one of the names dumped out by ‘sugar-list-bundles’ for ‘sugar-forget-bundle’ to be able to use it. ‘sugar-forget-bundle’ will remove the Activity’s record from the Sugar registry. It will NOT delete the directories or files associated with the Activity. For example:

./sugar-forget-bundle Sonata

will cause Sugar to “forget” that the Sonata Activity is installed. It will NOT remove /home/olpc/Activities/sonata.activity or any of the files under it.

I’m sure there must be equivalents to these two utilities floating around (especially around the OLPC XO development team), but I haven’t stumbled across them. I hope you find them handy.