User:SamuelRiv/Sugarization

From OLPC
Jump to: navigation, search

How to Sugarize Applications for the OLPC + Software include.

From: olpcnews forum msg 12203.

By CatMoran

To setup (one time):

Start a Terminal activity. Enter the following commands. (They log you in as root, gets a copy of Albert Cahalan's compiled libsugarize file, and gets the script I created.)

su
wget http://www.catmoran.com/olpc/libsugarize.so
chmod 755 libsugarize.so
wget http://www.catmoran.com/olpc/sug
chmod 755 sug

Optional, if you want to use the icons I've already '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:

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 I've created. (wget commands above.) plain.svg is a plain circle, ff.svg is a circle with FF (for firefox) inside, l.svg is a circle with L inside. ff.svg and l.svg can easily be edited for any two or one character(s). Open the file in any text editor. Each letter is in plain text just before the tags, replace them and save the file.

Enter the following commands, to log in as root and execute the sug script.

su
./sug

> You'll be prompted for an activity name. Enter a short, descriptive name with no spaces or punctuation, such as BibleTime or Firefox. > You'll be prompted for an icon file to copy into the new task. You can 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. > You'll be prompted for the command to start the program. This is the command you entered from Terminal to start the program, such as firefox. > You'll be prompted for an organization path, such as org.mozilla If you don't know what this is, just enter org.x

(If at any of the prompts you want to quit the script, just enter nothing at the prompt.)

The script will give you a success message. Reboot sugar to see the new task in the sugar taskbar.

original forum postscript - mirrors are down

NOTE: If the catmoran.com domain is down, see post #30 for a mirror of the files.

« Last Edit: March 27, 2008, 07:25:21 AM by CatMoran »


original liscence from archive.org

This item is part of the collection: Ourmedia

  • Identifier: Sugarize
  • Mediatype: other
  • Licenseurl: [1]
  • Publicdate: 2008-03-26 18:05:01
  • Addeddate: 2008-03-26 18:04:21
  • Filesxml: Sun Dec 5 23:42:16 UTC 2010
  • Keywords: OLPC

Creative Commons license: Attribution-Noncommercial-Share Alike 3.0

file links from archive.org

file type size & link
libsugarize Sugar .so 2.7 KB
sug exec script 3.7 KB
ff svg 1.4 KB
l svg 1.0 KB
plain svg 0.6 KB
Sugarize_files xml metadata file ?? KB
Sugarize_meta xml metadata 2.6 KB


Script code

All scripts from this page are reproduced below:

note: as of 04/28/2011 I have not yet modified this so that it actually works with the current build - hold your horsies on that.

sug

#!/bin/sh

CREATEPATH=/usr/share/activities/
ACTIVITYFILE=activity/activity/activity.info

echo "Enter [enter] at any prompt to exit without creating the task."

ACTIVITYNAME=" "
NOSUCHACTVITY=1
# until [ -z "$ACTIVITYNAME" -o \($NOSUCHACTVITY -eq 0\) ]
until [ $NOSUCHACTVITY -eq 0 ]
do
  echo "Enter a name for the activity. Use only numbers and letters:"
  echo -n "> "
  read ACTIVITYNAME

  NOSUCHACTVITY=0
  if [ -d "$CREATEPATH"/"$ACTIVITYNAME".activity -o -s /bin/sugar"$ACTIVITYNAME" ]
  then
     NOSUCHACTVITY=1
     echo "An activity exists by that name. Enter another name."
  fi

done
if [ -z "$ACTIVITYNAME" ]
then
	echo "No task created."
	exit 0
fi

ICONFILENAME=" "
until [ -z "$ICONFILENAME" -o -s "$ICONFILENAME" ]
do
  echo "Enter the full name of the icon to use for the activity, including the path:"
  echo -n "> "
  read ICONFILENAME
done
if [ -z "$ICONFILENAME" ]
then
	echo "No task created."
	exit 0
fi

EXECUTABLECOMMAND=" "
  echo "Enter the terminal command used to start the program."
  echo "ie, \"firefox\" or \"mplayer -f\""
  echo -n "> "
  read EXECUTABLECOMMAND
if [ -z "$EXECUTABLECOMMAND" ]
then
	echo "No task created."
	exit 0
fi

ORGPATH=" "
  echo "Enter the organization path of the program."
  echo "ie, the organization path for firefox is org.mozilla"
  echo "If you don't know what this is, enter \"org.x\""
  echo -n "> "
  read ORGPATH
if [ -z "$ORGPATH" ]
then
	echo "No task created."
	exit 0
fi

echo "Activity name: $ACTIVITYNAME"
echo "Icon filename: $ICONFILENAME"
echo "Executable command: $EXECUTABLECOMMAND"
echo "Org path: $ORGPATH"

# create directories
mkdir "$CREATEPATH"/"$ACTIVITYNAME".activity
mkdir "$CREATEPATH"/"$ACTIVITYNAME".activity/activity
mkdir "$CREATEPATH"/"$ACTIVITYNAME".activity/lib
mkdir "$CREATEPATH"/"$ACTIVITYNAME".activity/bin
 
# copy existing file names
cp libsugarize.so "$CREATEPATH"/"$ACTIVITYNAME".activity/lib
cp $ICONFILENAME "$CREATEPATH"/"$ACTIVITYNAME".activity/activity/"$ACTIVITYNAME".svg

# make sure libsugarize.so file is executable
chmod +x "$CREATEPATH"/"$ACTIVITYNAME".activity/lib/libsugarize.so

# create activity.info file
echo "[Activity]" >> "$CREATEPATH"/"$ACTIVITYNAME"."$ACTIVITYFILE"
echo "name = ${ACTIVITYNAME}" >> "$CREATEPATH"/"$ACTIVITYNAME"."$ACTIVITYFILE"
echo "service_name = ${ORGPATH}.${ACTIVITYNAME}" >> "$CREATEPATH"/"$ACTIVITYNAME"."$ACTIVITYFILE"
echo "icon = ${ACTIVITYNAME}" >> "$CREATEPATH"/"$ACTIVITYNAME"."$ACTIVITYFILE"
echo "activity_version = 1" >> "$CREATEPATH"/"$ACTIVITYNAME"."$ACTIVITYFILE"
echo "show_launcher = yes" >> "$CREATEPATH"/"$ACTIVITYNAME"."$ACTIVITYFILE"
echo "exec = sugar${ACTIVITYNAME}" >> "$CREATEPATH"/"$ACTIVITYNAME"."$ACTIVITYFILE"

# create /bin/sugarACTIVITYNAME file

BINFILE="$CREATEPATH""$ACTIVITYNAME".activity/bin/sugar"$ACTIVITYNAME"

echo "#!/bin/sh" > "$BINFILE"
echo "while [ -n \"\$2\" ] ; do" >> "$BINFILE"
echo "     case \"\$1\" in" >> "$BINFILE"
echo "         -b | --bundle-id)     export SUGAR_BUNDLE_ID=\"\$2\" ;;" >> "$BINFILE"
echo "         -a | --activity-id)   export SUGAR_ACTIVITY_ID=\"\$2\" ;;" >> "$BINFILE"
echo "         -o | --object-id)     export SUGAR_OBJECT_ID=\"\$2\" ;;" >> "$BINFILE"
echo "         -u | --uri)           export SUGAR_URI=\"\$2\" ;;" >> "$BINFILE"
echo "         *) echo unknown argument \$1 \$2 ;;" >> "$BINFILE"
echo "     esac" >> "$BINFILE"
echo "     shift;shift" >> "$BINFILE"
echo "done" >> "$BINFILE"
echo "export LD_PRELOAD=\"\$SUGAR_BUNDLE_PATH/lib/libsugarize.so\"" >> "$BINFILE"
echo "export NET_WM_NAME=\"${ACTIVITYNAME}\"" >> "$BINFILE"
echo "exec ${EXECUTABLECOMMAND}" >> "$BINFILE"

# make sugar file executable
chmod +x "$BINFILE"

echo "${ACTIVITYNAME} task created sucessfully. Reboot sugar (ctrl-alt-erase) to use."
exit 0

svg code

CatMoran's Sugar svg templates are reproduced at User:SamuelRiv/svg.