Difference between revisions of "Running Linux Applications Under Sugar"
Line 91: | Line 91: | ||
# Causes SeaMonkey to put the .mozilla directory in a | # Causes SeaMonkey to put the .mozilla directory in a | ||
# place that is writable, and also where Rainbow wants | # place that is writable, and also where Rainbow wants | ||
− | # it. | + | # it. SUGAR_ACTIVITY_ROOT is not suitable since it |
− | export HOME="$ | + | # contains a reference to a user that will be destroyed |
+ | # on reboot. | ||
+ | export HOME="/home/olpc/isolation/1/gid_to_data_dir/$GROUPS" | ||
# libgnomevfs ignores the HOME environment variable, | # libgnomevfs ignores the HOME environment variable, | ||
Line 104: | Line 106: | ||
# in HOME group-accessible (at a minimum, make | # in HOME group-accessible (at a minimum, make | ||
# .mozilla and everything in it group-accessible). | # .mozilla and everything in it group-accessible). | ||
− | chmod -R g+rwx $ | + | chmod -R g+rwx $HOME/.* |
− | chmod -R g+rwx $ | + | chmod -R g+rwx $HOME/* |
while [ -n "$2" ] ; do | while [ -n "$2" ] ; do |
Revision as of 22:35, 13 July 2008
Note: This article is about running standard Linux applications inside Sugar by using the Activities icon panel rather than starting them from the Terminal.
Sugar Coating
Many standard Linux programs can be run within Sugar, but without the collaboration and other Sugar integration programmed into them. The process of adding an icon to the Sugar Activities panel is called "Sugar Coating".
A simple script to automate the process was created by a woman named CatMoran. The script:
- has be confirmed to work with Firefox, Seamonkey, Midnight Commander, TuxType2, TuxPaint and Totem. It it presumed to work with many other Linux programs.
- only works with programs that use the same command every time (i.e., a single command with no qualifiers). It doesn't work for roto's current mplayer configuration, because the mplayer command requires an input file name to start the program.
To setup (one time):
- Start a Terminal activity.
- Enter the following commands: su wget http://www.catmoran.com/olpc/libsugarize.so chmod 755 libsugarize.so wget http://www.catmoran.com/olpc/sug chmod 755 sug (What do those commands do? They log you in as root, gets a copy of Albert Cahalan's compiled libsugarize file, and gets the script CatMoran created.) Optional, if you want to use one of the icons CatMoran created: wget http://www.catmoran.com/olpc/plain.svg wget http://www.catmoran.com/olpc/ff.svg wget http://www.catmoran.com/olpc/l.svg
To Run (once per program that you want to Sugar Coat):
- Locate an icon you want to use/reuse.
- You can copy any .svg file located in /usr/share/activities/*.activity/activity/*.svg
- Or you can use one of the icons CatMoran created--and downloaded using the wget commands listed above. plain.svg is a plain circle, ff.svg is a circle with the letters FF (for Firefox) inside, l.svg is a circle with the single letter L inside. Both of the latter files can be easily edited using any text editor and one or both character(s) changed. Each letter is in plain text just before the </tspan> tags, replace them and save the file.
- Enter the following commands, to log in as root and execute the sug script. T quit the script at any time, just enter nothing at the prompt and hit the Enter button. su ./sug First, you'll be prompted for an activity name. Enter a short, descriptive name with no spaces or punctuation, such as BibleTime, Firefox, or MC. Second, you'll be prompted for an icon file to copy into the new task. Enter the full path and filename of any .svg file. If the icon is in the same directory as the sug file, you can enter just the filename. Next, you'll be prompted for the command to start the program. This is the command you type at the Terminal prompt to start the program, such as firefox, totem, or mc. Finally, you'll be prompted for an organization path, such as org.mozilla If you don't know what this is, just enter org.x The script will give you a success message. Reboot Sugar by pressing Ctrl-Alt-Erase (the Control, Alt and Erase buttons) at the same time. When Sugar restarts you will now see the new icon in the Sugar taskbar. A simple click on the icon will start the newly Sugar Coated program, like any other Sugar Activity.
Sugar Coat Script Mirror Servers
- Main Page - http://www.archive.org/details/Sugarize
- The HTTP - http://ia341002.us.archive.org/3/items/Sugarize
- The FTP - ftp://ia341002.us.archive.org/3/items/Sugarize
Source - http://olpcnews.com/forum/index.php?topic=1555.0
Comments
I haven't been able to get this to work in Update.1 --leetcharmer
Rob - I modified the script to work in Update 1 for SeaMonkey, but it requires an effective disabling of security. The crux of the problem is that Rainbow runs your application as a totally new user each time (never as "olpc"), and that these "on-the-fly" users don't have write access to their home directories. All of these users are created in the same persistent group, and all share write access to a common "data" directory for the group. (The preceding is just a paraphrase of the Rainbow docs - should likely be a link). In the case of non-Sugar apps, the application has no idea that the usual role of a user has been migrated to a group, and so the application is unlikely to create it's data files with the correct permissions.
Note Well: The following instructions essentially remove all security on your machine. If you have set passwords on any of the machine accounts (root, olpc, etc.), likely you don't want to execute these instructions.
[olpc@xo ~]$ su [olpc@xo ~]# chmod a+s /bin/chmod
These lines allow any user to change permissions on any file and/or directory in the system. Therefore, having something only readable / executable by root is no longer a protection, since an unprivileged user can just change the permissions. In my case, I couldn't lose what I didn't have -- I have no password for the root or olpc users, so there was no effective change.
In general sudo would be a more graceful approach to this problem, but I couldn't get it to work in a script (first, you need to allow all uids > 10000; second, you need it to not prompt for a password; and third, su can't be invoked from a Sugar script because stdin is not a tty, even if no password is required).
After using the above to allow the Rainbow "on-the-fly" users to change permissions on files they don't own, we use the chmod ability in the script. The following script is just CatMoran's script with a few lines added at the beginning. Any other minor formatting changes are accidental and a result of my editing the file 100 times to try to find out why it wasn't working. I've only tested this script with SeaMonkey -- but I think similar ideas would work for other applications.
#!/bin/sh # Causes SeaMonkey to put the .mozilla directory in a # place that is writable, and also where Rainbow wants # it. SUGAR_ACTIVITY_ROOT is not suitable since it # contains a reference to a user that will be destroyed # on reboot. export HOME="/home/olpc/isolation/1/gid_to_data_dir/$GROUPS" # libgnomevfs ignores the HOME environment variable, # so make our actual home directory writable for the # .gnome2 and .gnome2_private directories. chmod g+w $SUGAR_ACTIVITY_ROOT # SeaMonkey ignores umask and makes everything # only user-accessible. But, we're running as # a different user each time. So make everything # in HOME group-accessible (at a minimum, make # .mozilla and everything in it group-accessible). chmod -R g+rwx $HOME/.* chmod -R g+rwx $HOME/* while [ -n "$2" ] ; do case "$1" in -b | --bundle-id) export SUGAR_BUNDLE_ID="$2" ;; -a | --activity-id) export SUGAR_ACTIVITY_ID="$2" ;; -o | --object-id) export SUGAR_OBJECT_ID="$2" ;; -u | --uri) export SUGAR_URI="$2" ;; *) echo unknown argument $1 $2 ;; esac shift;shift done export LD_PRELOAD="$SUGAR_BUNDLE_PATH/lib/libsugarize.so" export NET_WM_NAME="SeaMonkey" exec /usr/bin/seamonkey