Understanding Sugar code

From OLPC
Revision as of 16:52, 22 February 2007 by Jcfrench (talk | contribs)
Jump to navigation Jump to search

OK, Sugar runs on an OLPC. The OLPC runs a stripped down Fedora Linux Operating System.

Open the Developer Console, and go to the Terminal tab. Click in the Terminal window, and switch to the root account:

To do this, let's use the superuser command, "su".

[olpc@localhost]$ su

What runs as part of sugar? Let's see what processes have the keyword sugar using both the "ps" command to list processes, and the grep command to filter for the processes with the word "sugar" in them.

bash-3.1# ps -eaf | grep sugar
olpc 1290 1285 3 15:46 ? /usr/bin/python /usr/bin/sugar-shell 
olpc 1293 1290 0 15:46 ? matchbox-window-manager -kbdconfig /usr/share/sugar/kbdconfig ... 
olpc 1296    1 0 15:46 ? dbus-launch --exit-with-session sugar-shell
olpc 1298    1 0 15:46 ? /usr/bin/python /usr/bin/sugar-presence-service 
olpc 1302    1 0 15:46 ? /usr/bin/python /usr/bin/sugar-clipboard
olpc 1304    1 0 15:46 ? /usr/bin/python /usr/bin/sugar-nm-applet
olpc 1306    1 4 15:46 ? python /usr/bin/sugar-console
olpc 1339 1285 1 15:46 ? grep sugar

Most things seem to run on python, not a big suprise. But right here, we can see some key architectural divisions:

  1. A shell
  2. A presence service (the right side of the sugar interface)
  3. A clipboard (The left side of the sugar interface)
  4. A nm applet utility of some kind (This might be the bottom stuff in the sugar interface)
  5. A console (probably the development console)

Also, there are two non-python type processes running, dbus-launch, and a matchbox-window-manager. I think matchbox is an automated test utility (notice it's spawned from the sugar-shell), and the dbus is for Inter-process communications (supporting the presence service, amongst other things)

So the questions are...

What starts the sugar shell? What is each service or utility?


It looks like most of these python scripts are stored in /usr/bin. We can read the python scripts and see what they do.

less /usr/bin/sugar-shell

This thing starts a sugar environment. It also relies on a lot of other stuff, and it looks like the OLPC developers expect a lot of changes here as they make progress on getting sugar into shape. It references GTK, dbus, nm applet, and lots of stuff.

less /usr/bin/sugar-nm-applet

Oh, look, this is the network manager utility. OK, and then the activity factory will be triggered whenever a new activity is selected on the bottom....