ExecCommand (activity): Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:
|mime_types =
|mime_types =
|i18n = en
|i18n = en
|comments = To see an example of this activity modified to just start XMMS, check out [http://jtolds.googlepages.com/Xmms.xo Xmms.xo]. All that was modified was bin/exec-script.sh, activity/activity.info (for the name), and activity/icon.svg.
|comments = To see an example of this activity modified to just start XMMS, check out [http://jtolds.googlepages.com/Xmms.xo Xmms.xo]. All that was modified was bin/exec-script.sh, activity/activity.info (for the name), and activity/icon.svg. Of course, this requires [[XMMS]]
|tags = exec,sugarizing,unix,commands
|tags = exec,sugarizing,unix,commands
}}
}}

Revision as of 21:32, 12 February 2008

ExecCommand.svg ExecCommand: A very simple utility. On launch, this activity either launches a predefined Unix command, or starts an graphical dialog and queries the user for what command to run. Useful for starting vncviewer or xmms.
To see an example of this activity modified to just start XMMS, check out Xmms.xo. All that was modified was bin/exec-script.sh, activity/activity.info (for the name), and activity/icon.svg. Of course, this requires XMMS
Download: ExecCommand.xo (v.1)
Source:
Build: all
Mime types:
Internationalization: en
Tags: exec,sugarizing,unix,commands
Development Status: ?


Summary

This utility is targeted at experienced Linux/Unix users who hope to feel more at home with the XO. On launch, this activity either launches a predefined Unix command (you have to edit the script contained in the activity), or starts an graphical dialog and queries the user for what command to run. Useful for starting vncviewer or xmms.

Current Implementation

You can find the current version at http://jtolds.googlepages.com/ExecCommand.xo. This version starts a simple xdialog that requests for a command to run. Also, there is a modified version that just starts XMMS. http://jtolds.googlepages.com/Xmms.xo

Justification for implementation

Looking through the Sugarizing page, it seems fairly clear that getting an Activity to simply start a non-activity application cleanly is non-trivial. Many attempts end up leaving a "loading" icon for the activity, or have multiple icons displayed as running activities, or other things.

Native X applications on the XO simply show as a little circle icon, but a lot of work has gone into customizing this behavior for specific X applications.

Personally, I couldn't care less what the icon looks like in the running activities disc, just so long as I can easily start my desired app.

I realized a simple solution would be to create an Activity that simply starts, forks a new app in the process, and then closes itself, cleaning up all of the Activity mess left behind from a rapid exit.

Implementation

import os
# get the exec script started right away.
os.system("bin/exec-script.sh &")

from sugar.activity import activity

class ExecActivity(activity.Activity):

   def __init__(self, handle):
       activity.Activity.__init__(self, handle)

       self.set_title('Executing...')

       # this strategy doesn't seem to work if there's no toolbox
       toolbox = activity.ActivityToolbox(self)
       self.set_toolbox(toolbox)
       toolbox.show()

       # close, removing the unuseful icon from the activities disc
       activity.Activity.close(self)

In retrospect, os.fork/execv would have been a better choice than os.system.

Author

If you need to contact me or have a suggestion for an improvement, please visit http://jtolds.com/contact/