Development Team/Almanac/Activity Bundles

From Sugar Labs
Jump to: navigation, search


Activities in the Sugar environment are packaged into a self-contained "bundles". Each bundle contains all the resources and executable code (other than system-provided base libraries) which the activity needs to execute. Any resources or executable code that is not provided by the base system must be packaged within the bundle. Activity bundles are the end result of, and use a different directory structure than, activity development

See also


Activities are meant to be shared between children. If a child doesn't have the activity, it is automatically transfered to the child when he or she joins the shared activity. Packaging activities in self-contained bundles allows easy sharing, installation, removal, and backup.


Activities are installed and removed automatically by Sugar, in response to user actions. Sugar places activities in directory of its choice. Activities should not rely on being installed in a specific location, and should use relative paths where paths are necessary (i.e., for shared library linkage, activity resources such as images, sounds, etc). They should also not rely on the bundle's base directory name remaining the same. Sugar may rename the activity bundle base directory at any time to prevent bundle conflicts.

Currently Sugar on jhbuild looks for bundles in the "activities" subfolders of XDG_DATA_DIRS. Right now this is /usr/share/activities and the usr/share/activities subfolder of the jhbuild build folder.

Sugar will automatically generate and remove the .service files necessary to launch the activity through olpc:D-BUS service activation when the activity is installed or removed.

Activities should also NEVER store local state or preferences in the activity bundle itself. These should always be stored in an activity-specific directory in the user's sugar profile, available through the SUGAR_PROFILE environment variable.

Python developers can also get the profile folder this way:

import sugar.env
profile_path = sugar.env.get_profile_path()

Bundle structure

The activity bundle is a directory, with a name ending in ".activity". Each activity bundle must, in a subdirectory called 'activity', contain a file named "", and following a special format. For example:

    activity/                          (activity info file)
        activity-web.svg                       (icon for activity as specified in
        mimetypes.xml                          (map documents to MIME types)
        text-plain.svg                         (icons for documents, e.g. "text-plain.svg" for "text/plain")
        web-activity                           (launcher script or activity executable)
            activity.linfo                     (localized info 1)
            activity.linfo                     (localized info 2)
    lib/                               (native library)

All metadata about the activity is organized in this subdirectory. The contents and contents.sig are manifest and credential files for the entire bundle contents (excepting the contents and contents.sig files themselves), as described by the olpc:Contents manifest specification; these files are not supported by current versions of Sugar. The optional mimetypes.xml file is a MIME type file describing how to recognize the MIME types defined by the activity. SVG icons for those MIME types can be put in this directory as well.


Contains executables, is added to the PATH environment variable.


See #Bundling native libraries below.


See #Activity name localization/translation below.


Contains the icons used by the activity. When using the sugar.activity python package the path is automatically added to the default gtk icon theme.

.info file format

.info files follow a key/value pair format, similar to the fd.o desktop entry spec, but not conforming to it. An example is shown here:

name = Browse
activity_version = 156
bundle_id = org.laptop.WebActivity
icon = activity-web
exec = sugar-activity webactivity.WebActivity -s
mime_types = image/png;image/gif;image/jpeg;text/html;text/uri-list;application/xhtml+xml;application/rss+xml;application/xml;text/css
license = GPLv2+
summary = Surf the world! Here you can do research, watch educational videos, take online courses, find books, connect with friends and more.
update_url =
tags = exploration;web
single_instance = no
max_participants = 4
repository =

A more detailed explanation of the valid properties follows:

The file must begin with [Activity], and only that, on the first line of the file
name = Browse
This is the name is displayed in Sugar referring to the activity. A 'name' key without a bracketed language code is the "en_US" localized name of the activity. The file must have this key.
activity_version = 156
Each file must have a "activity_version" key. Example versions are 1, 1.2, 1.2.3, 1.2.3-peru, and 1.2.3~me. Larger versions are considered "newer". An activity should not use the value, as it may be changed by developers and packagers. The value must be newer for newer activities.
host_version = 1
This key is deprecated. This used to specify the version of the Sugar environment the activity is compatible with; however, it was never implemented.
bundle_id = org.laptop.WebActivity
This is the activity bundle identifier. It is required. The name should conform to the D-Bus spec - in particular, hyphens are not allowed (although this wasn't enforced in earlier builds, see Trac 6226). It is recommended that Java package naming conventions are used when choosing bundle identifiers, to ensure uniqueness. Briefly, your name should begin with the reversed domain name of an organization you belong to.
The reversed domain name part is supposed to be rooted in some actual DNS-rooted namespace. You don't need to own this domain; you just need to have a reasonable claim on some unique name at that domain. There are several ways to derive one:
  • If your email address is, then you could use com.somemailhost.yourname.YourActivity.
  • You could set up a web page on a free hosting service with information about your activity, and use a name derived from its URL. For example, if you create a page at for your activity, then com.geocities.www.xotumusica is a reasonable bundle_id.
  • If nothing else is available, even Activity Page Title is probably a reasonable bundle_id, provided that you create the 'Your Activity Page Title' page. Remember, bundle_ids should be unique, so you should double check that the 'Your Activity Page Title' page doesn't already exist (and then create it) before using this as your bundle_id.
In the Python bindings, the bundle_id is also used as the activity's default service type when the activity is shared on the network. To determine this type, the distinct parts (separated by the '.' character) are reversed, any '.' is replaced by a '_' character, and the type is prefixed by a '_' character. So in this example, the default service type would be "_WebActivity_laptop_org".
license = GPLv2+
This field names the license used for the activity bundle (the binary .xo file). The contents of this field should conform to the same guidelines as the License: field of an RPM package; consult the Fedora Licensing Guidelines for more information. A 'license' field naming an entry or entries in the "Good Licenses" table at Fedora's Licensing list is required for any activities distributed by OLPC.
icon = activity-web
It points to the activity's icon. The icon is looked up in the activity bundle's 'activity' directory (the same directory the file is in). It cannot contain a path. When searching for the icon in the activity bundle's 'activity' directory, only a file with the icon name and the extension '.svg' will be looked for. This property is required unless 'show_launcher' is 'no' (see below).
exec = sugar-activity webactivity.WebActivity -s
The exec key specifies the executable which Sugar runs to start the activity instances. Environment variables given on the exec line are expanded. Executable files should be placed into the bin/ directory in the bundle. It should support the following arguments:
-b, --bundle-id  
Identifier of the activity bundle
-a, --activity-id 
Identifier of the activity instance.
-o, --object-id  
Identifier of the associated datastore object.
-u, --uri  
URI to load.

Python activities should generally use the generic sugar-activity executable. Other activities need to adhere to the olpc:Low-level Activity API.

mime_types = application/pdf;image/tiff
List of mime types supported by the activity, separated by semi colons. It's used when opening a file from the web or to present to the user a list of activities which can open a certain journal object.
show_launcher = yes
This key is optional. If not present, or if present with a value of "yes", the activity is shown with its icon in the Sugar panel launcher and a valid 'icon' key/value pair is required. If specified with a value of "no", the activity is not shown in the Sugar panel launcher, and the 'icon' key is not required.
update_url = ...
URL to retrieve update information; implemented in #4951. The software update control panel will attempt to look for information about the latest version of the activity by fetching the given url with first the core OS build number, then the release number, then the release major version number appended, then finally as-is. (For example, if your update URL tag has the value '' and you are currently running release 8.1.1 (core OS 708), the following URLs will be tried, in this order:,,, .) The contents of the URLs should be in the olpc:Activity microformat. If no update_url is specified, will be used. See olpc:Software updater for more information.
tags = exploration;web
Tags give more context in which to place the activity. This is used to allow users to find activities more easily in the journal, the home view,, etc.
single_instance = yes
This key is optional. If not present, or if present with a value of "no", multiple instances of the activity can be launched at once. If present with a value of "yes", then only one instance of the activity will be open at any one time. This key was added in order to flag activities that use resources that cannot be shared.
max_participants = 4
This key is optional. If not present, or if present with a value of <=1, the activity is not shared. Otherwise, it limits the number of participants who can join a shared activity. Note that setting max_participants in is deprecated.
summary = ...
A short summary of the activity is displayed in the List View.
repository = https://...
The URL of the master git repository for the activity, for use by git clone. Since activities are not all hosted in a single repository, it is important to include a link so that users can readily find the activity. Some git hosting services allow the URL to be used by web browser as well as git clone.

Localization/translation of the activity name and tags

Localized data lives in the locale directory. Each language stores its localized keys in a separate directory named for the language's ISO code. Localized keys from the '' file are stored in the 'activity.linfo' files in that directory. For example, German-localized German (as opposed to Swiss-localized German) language translations are stored in the 'de_DE/activity.linfo' file:


At this time, only translations for the 'name' and 'tags' keys from the '' file is supported. A localized 'de_DE/activity.linfo' file would look like:

name = Web
tags = erforschung;web

Keys in the languague-specific '.linfo' files selectively override keys from the '' file; if a key is not present in the '.linfo' file the value from the '' file is used instead.

Package, extension, mime type

Activity bundles should be packaged as zip files with the ".xo" extension. The mime type in the journal is "application/vnd.olpc-sugar".

Bundling native libraries

Sometimes you need to include a native library or two with your activity. The strategy that olpc:Develop and olpc:Model use is specifying a shell script for the executable in the .info file:

exec = ./

The script, '', modifies the library path, python, or both paths (depending on the types of libraries you are including) to reference folders inside your bundle, then launches your application:



sugar-activity model_app.ModelActivity

Make sure to add your shell script and any native libraries to the MANIFEST before you package your bundle. You can also accomplish the same thing by throwing all your libraries in the root folder of the bundle, like the Map activity does, but if you have more than a few libraries to include it can get quite cluttered.


Note: the API described in this section is DEPRECATED.

Bitfrost describes a variety of security-related settings which activity authors can specify about their activity. At the option of the activity author, these settings can be described in a file called '' which can be placed alongside '' in the 'activity' directory of the bundle.

As of rainbow-0.7.21, writing the single line


into the file will result in your activity being launched with the same uid each time it is run. (Usually each activity gets a constant gid, but each instance launched of the activity gets a unique uid. Activities based on the xulrunner codebase, however, tend to set restrictive group permissions on local files, so this option avoids this problem at the cost of less isolation between activity instances.)

As of rainbow-0.7.22, the line:


will add the activity UIDs to the 'uucp' group, so that the activity can access /dev/ttyUSB* devices. (See <trac>8434</trac>.)

Other options which may be specified include:

lim_nofile 20
lim_fsize 10e6
lim_nproc 8
lim_mem 190e6

which will limit the number of file descriptors, the maximum writable file size, the number of processes, and the maximum size of the activity's address space, respectively. (See man 2 setrlimit for details.)

Other technologies comparison

Activity bundles are similar to OS X bundles or Java JAR files; a simple mechanism to encapsulate everything you need in a single directory that can be moved around independently.

It differs from autopackage, it's not a package management system. There's no central database, no scripts get run on install/uninstall. There also is no special file format.

As compared to klik, it's not intended to replicate a local Unix directory structure inside the package; the activity can still link to system provided binaries and such. There's also no server-side component other than compressing the archive and sending it over the network.There is also no dependency checking since activities are required to be self-contained.

See also