*

Welcome, Guest. Please login or register.
Did you miss your activation email?

Check out the new and improved 2010 Xtra Ordinary OS for the XO laptop!
Pages: [1] 2 3 4
Print
Author Topic: How-to create a "stub/shortcut/launcher" Activity?  (Read 31345 times)

How-to create a "stub/shortcut/launcher" Activity?

sracer
Master Contributor
***
Posts: 285


January 16, 2008, 07:20:17 PM

Having installed BibleTime and MC (neither of which are not native Sugar apps), I was wondering if it would be possible to create "shortcuts" (in Windows terminology) for those apps and have them show up in the activity bar at the bottom of the screen.

I'm thinking it would be a simple activity that launches the underlying executable and has a custom icon. 

Before I go stumbling and fumbling around to try to create one, does someone already something written?
Logged

#1 Re: How-to create a "stub/shortcut/launcher" Activity?

jenpc
Contributor
*
Posts: 66

Received March 26, 2008!


January 17, 2008, 07:07:06 AM

Phrased another way, the question is "How do I sugarize an existing application"?

The answer depends upon certain details about the application.  Some lend themselves more easily to sugarization than others.  How to do this has been one of my burning questions also, and last night when I was looking into it again I finally found some promising leads.

But first, before I forget, here's a brainstorm about how we might be able to more readily run applications that don't lend themselves so easily to sugarization.  What if someone wrote a sugar activity that served as an application chooser?  An initial version could be a very simple activity that had a static list of applications and selecting one would perform the equivalent of typing the appropriate command in the Terminal to start it.  A later version could have buttons to Add, Edit, and Delete the application choices, and the ability to respond to a letter key press (e.g. M for Midnight Commander) instead of just clicks.

OK, back to sugarization.  First a few links that could help in the process of understanding activities:
And of course some of the usual suspects from the laptop.org wiki:

If it's a java GUI then this post might serve as a starting point http://frequal.com/java/FirstLookOnTheOlpcXoLaptop.html.

If you want to sugarize a Mono application then this blog has information on that: http://tquerci.blogspot.com/2008/01/mono-on-olpc-one-laptop-per-child.html

To sugarize a single-window X application, we can borrow from Albert Cahalan's hard work.  He has written a program called "sugarize" which he describes as a wrapper that makes any normal single-window X program sugar-compatible.

Do the applications that you're interested in meet the criteria?  I don't know yet.  But here are links for information on it.

That post contains a description, the links from the first 2 bullets, and a response by someone who wrote a shell script to use in place of the xlogo.activity/bin/sugarize in Albert Cahalan's code.  I haven't studied it yet.  It could be that the shell script means that you don't need the Makefile, libsugarize.c, or sugarize.c.  If that's the case, it reduces the task to:
  • Coming up with an icon (.svg)
  • Writing a short, simple activity.info file
  • Editing the shell script provided to call your activity instead of xlogo
  • Making the directory for the activity and putting everything in its place there
  • Running the shell script to create an activity wrapper for your application!

I don't know if it's as simple as that, and unfortunately I don't expect to have enough time to try in the next week.

One other thing that could be useful once the activity is wrapped is being able to change where it appears in the list of activities at the bottom of the screen.  That's answered in this post: http://olpcnews.com/forum/index.php?topic=327.msg2998#msg2998.  See the following message in that thread also.

Sorry I don't have any firm answers, but hopefully this gets you started.  Good luck!  Please keep us posted on your progress and any stumbling blocks.  And maybe we'll hear from someone else who has already tried it.

-Jen
Logged

#2 Re: How-to create a "stub/shortcut/launcher" Activity?

sracer
Master Contributor
***
Posts: 285


January 17, 2008, 09:24:09 AM

Thanks for the comprehensive information... it will definitely be helpful if I need to go that route.

...I'm not looking to "sugarize" existing apps (if I'm understanding the concept correctly).  I want to use apps like MC and BibleTime off-the-shelf (so to speak) and simply create a shortcut to launch them from the Sugar activity bar.

The information and links that you provided probably include what I need to do that.

Right now, I have to open a terminal session and run: MC (for midnight commander) or bibletime (for the bible reader).  What I'm looking for is a way to automate the invocation of them directly from the activity bar.  I 
Logged

#3 Re: How-to create a "stub/shortcut/launcher" Activity?

jenpc
Contributor
*
Posts: 66

Received March 26, 2008!


January 17, 2008, 07:03:06 PM

Yes, it was way more information than you asked for since I didn't have a short answer and I was afraid that partial sugarization would be the only possible solution.

I squeezed in a bit more time to play with it tonight and got BibleTime to work that way using Albert Cahalan's sugarize method combined with the shell script I mentioned.  After that I tried without the libsugarize.so and it seems to work ok that way too, until you exit BibleTime and realize that as far as Sugar is concerned the activity is still "Starting".  (Yes, that's with removing the line in the shell script that mentions the library.)  So you could omit the stuff about libsugarize.so as long as you don't mind that you can only run BibleTime once (using the icon in the activity tray) per session.

I did also try to do it without using the shell script - i.e. in the activity.info file use "bibletime" or "/usr/bin/bibletime" as the exec, but it hung while "Starting" and never started BibleTime at all.

So based upon my experiences to-date, at least partial "sugarization" is necessary to get an application to run that way in Sugar.  I'd be happy to be proven wrong and shown a simpler method!

So the best that I could come up with is this, using BibleTime as the example application.  Understand that neither the library nor the script is mine, I can't fully explain them, nor can I say I'm using them entirely correctly.  I can say that what I did worked for me.  I also apologize that I don't have time to make this description completely friendly to those brand new to Linux.  We should be able to come up with a simpler method to download an entire sample wrapped activity straight into Sugar, and then modify it from the terminal.  Then it'll be easier to document.

First you need to get libsugarize.so from this website (http://dev.laptop.org/git?p=users/albert/sugarize).  You can probably figure out a better way, but what I did was use the Browse activity to go there, (go to initial_commit), and then download libsugarize.so.  Then you need to (in Terminal) go to /home/olpc/.sugar/default/datastore/store, where Browse saves files, "ls -la" to see which 2 files are the most recent, and then use "more" or another viewer to see which file is text (you don't want the text file).  On my emulated system the size of the correct file shows up as 2792 using "ls -la".  Once I identified the file I copied it to libsugarize.so so it would have a simpler name.

From here on you need to be root (superuser) to do most if not all things because they occur in the /usr/share/activities directory.

Create a directory /usr/share/activities/BibleTime.activity (the command for this is mkdir dir_name).

In that directory make subdirectories "activity", "lib", and "bin".

Copy (using the "cp" command) the libsugarize.so file to the /lib directory that you just created in your new activity.

Go to the /bin directory, use your favorite plain text editor (e.g. vi) to create a file called sugarize and enter the text of the shell script there.  (The script is available from this post (http://lists.laptop.org/pipermail/devel/2008-January/009387.html)).  Edit it such that the 2nd to last line of the script exports the name "BibleTime" and the last line is "exec bibletime".  Once you're done editing the file, be sure to make it executable ("chmod +x sugarize").  Note that if you want to test the executable first from the Terminal, then for it to find the libsugarize.so properly you will need to create a /lib directory under the Terminal.activity and copy the library there.

Now go to the activity subdirectory of your BibleTime.activity.  You need 2 files, the icon.svg and the activity.info.  For an icon I copied the activity-acousticmeasure.svg from the AcousticMeasure.activity.  I also copied the activity.info file from the same activity and modified it for my purposes.  The text of my activity.info file looks like the following:

[Activity]
name = BibleTime
service_name = org.x.BibleTime
icon = activity-acousticmeasure
activity_version = 1
show_launcher = yes
exec = sugarize

And I think that's it.  You need to restart Sugar, of course, to try it out. 

Once you've done this for one activity, you should be able to copy the whole activity directory to another activity name, and then just get another icon and then edit the sugarize file and the activity.info file.

In some ways I'm sure it looks silly to have gone through all that effort when in theory I could have just installed "git" and gotten the example xlogo files that way.  But I haven't used "git" before and didn't want to spend time on that in case it took too long.  Maybe someone can explain that, or post an example activity wrapper in another format that's easy to download using "wget" and then extract.  I'm all for simplifying it further!
Logged

#4 Re: How-to create a "stub/shortcut/launcher" Activity?

jenpc
Contributor
*
Posts: 66

Received March 26, 2008!


January 19, 2008, 05:18:24 AM

Just thought of something this morning that should simplify the process.

Rather than downloading ibsugarize.so, you can download the entire sample xo activity -  http://dev.laptop.org/~albert/xlogo-1.xo.  Follow the usual steps to install an activity.  Then in the terminal go to /usr/share/activities.  You can modify it directly, or make a copy of the entire directory (e.g. "cp -r xlogo.activity xlogo.activity.template" to copy recursively if I remember correctly).  Once you've saved a copy just in case, you can modify the original xlogo.activity directory.  First step is to rename it for your activity (e.g. "rn xlogo.activity bibletime.activity").

Then if you're comfortable in C and building makefiles you can go that route and modify the Makefile.  (Note that this might be the best method if you want to be able to create an activity (.xo) from your application to share with others.  But if you've never done this sort of thing before then don't do it based upon the following sparse and incomplete directions!)  I believe the gcc compiler is included on the OLPC so hopefully there's no need to download anything else.  If there is I'm sure it's a simple yum install.  Replace each instance of "xlogo" in the file with your activity name (no spaces!  this should be the name you gave to the activity directory above (without the .activity)).  Except for the "/usr/bin/xlogo" - that needs to be replaced with the path to your executable, which may or may not be in /usr/bin.  And then of course there's doing the actual makes.

(Recommended:)  If you don't want to bother with the make process then use the shell script method instead and modify that script.  You could delete the following files that were included in the .xo downlaod: "Makefile", "libsugarize", "sugarize", and "sugarize.c".  Make a directory inside your activityname.activity called "lib" and move or copy libsugarize.so there. 

In either case you want to modify both files in the activity subdirectory inside activityname.activity.

Sorry I don't have time to test it now.  But I think downloading the .xo would be simpler than downloading the .so, especially with Browse.
Logged

#5 Re: How-to create a "stub/shortcut/launcher" Activity?

CatMoran
Senior Contributor
**
Posts: 168


WWW
January 19, 2008, 05:54:50 PM

I went through jenpc's last two posts, and created a script that automates most of the steps. I know that this works for firefox, I can't vouch for any other program. I know that it does not work for mc. It also doesn't work for roto's current mplayer configuration, because only programs that use the same command every time (ie, no input file name, in this case) can be set up to run this way.

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 </tspan> 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.

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 » Logged

#6 Re: How-to create a "stub/shortcut/launcher" Activity?

Pax
Commenter

Posts: 12


per Asperam ad astra


January 20, 2008, 08:48:19 AM



su

wget http://www.catmoran.com/olpc/libsugarize.so

chmod 755 libsugarize.so

wget http://www.catmoran.com/olpc/sug

chmod 755 libsugarize.so

Shouldn't this last one be:
chmod 755 sug   ?
Logged

#7 Re: How-to create a "stub/shortcut/launcher" Activity?

CatMoran
Senior Contributor
**
Posts: 168


WWW
January 20, 2008, 12:43:02 PM

Pax, yes. Yes it should. Oops. D:

Btw, I've uploaded another 'generic' icon to http://www.catmoran.com/olpc/l.svg

Both ff.svg and l.svg can easily be modified for any one (for l.svg) or two (for ff.svg) characters. Open the file in any text editor; the letter(s) are in plain text just before the </tspan> tags.

Also, lucidlife 'sugarizes' with this method.
Logged

#8 Re: How-to create a "stub/shortcut/launcher" Activity?

jenpc
Contributor
*
Posts: 66

Received March 26, 2008!


January 26, 2008, 02:30:09 PM

CatMoran - I just tried this out with Sylpheed (an e-mail client, see http://olpcnews.com/forum/index.php?topic=1409 for installation instructions) and it works great! Smiley  One thing I noticed, though, is that the "sug" script is putting the sugar-script (sugarSylpheed, in my case) in /bin instead of in the activity's bin directory (which is empty).  Would you edit your sug script accordingly so it doesn't touch the /bin directory?

edit:  It works for Pidgin (IM client) also!
« Last Edit: January 26, 2008, 06:29:02 PM by jenpc » Logged

#9 Re: How-to create a "stub/shortcut/launcher" Activity?

CatMoran
Senior Contributor
**
Posts: 168


WWW
January 27, 2008, 07:43:27 AM

CatMoran - I just tried this out with Sylpheed (an e-mail client, see http://olpcnews.com/forum/index.php?topic=1409 for installation instructions) and it works great! Smiley  One thing I noticed, though, is that the "sug" script is putting the sugar-script (sugarSylpheed, in my case) in /bin instead of in the activity's bin directory (which is empty).  Would you edit your sug script accordingly so it doesn't touch the /bin directory?

edit:  It works for Pidgin (IM client) also!

I edited sug to put the sugar script into the activity's bin directory, you can get the new copy of itt the same way as last time:

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

I did have one odd experience while testing the change. At the moment I only have two programs installed that can be sugarized this way, so I'm having to reuse them for testing. For one of them I did the following:

- deleted the old /bin/sugarACTIVITY and /usr/share/activities/ACTIVITY.activity
- ran ./sug to resugarize the activity
- ctrl-alt-erase

When Sugar came back up:
- I clicked the icon for the activity.
- The icon appeared in the home ring, blinked for a moment, and focus passed to the activity. (The program has a very small footprint and starts quickly.)
- A moment later, focus returned to the home view. The original icon for the activity was in the ring unblinking, but a second icon for it had appeared and was blinking. And blinking, and blinking.
- I went back to the first, running copy of the activity for a few minutes, then closed it.
- On return to the home view, the second icon was still blinking.
- I hit ctrl-alt-erase

When Sugar came back up the second time, I clicked the icon for the activity and the icon appeared only once and everything acted normally. I clicked it again, and got a second, running copy of the job.

I don't know if the problem with the always-starting icon the first time was caused by an accidental very fast double click, if it was because I removed the first sugarize files and recreated them with no reboot in between, or if it was just a fluke.

If you could watch for this and let me know if it happens to you, particularly on any 'fresh' sugarizations, I'd appreciate it!
Logged

#10 Re: How-to create a "stub/shortcut/launcher" Activity?

SethPowsner
Commenter

Posts: 9


January 27, 2008, 09:01:48 AM

On the off chance it's helpful, you could take a look at my post in the
mplayer thread. It includes the basics of python application wrapper.
http://olpcnews.com/forum/index.php?topic=863.msg13662#msg13662
Logged

#11 Re: How-to create a "stub/shortcut/launcher" Activity?

Grampa
Senior Contributor
**
Posts: 170


February 01, 2008, 12:40:50 AM

Thank you all for coming up with this. It's a big help. CatMoran, I used your instructions and sug script to sugarize a couple of programs. It works great for SeaMonkey, which is not surprising, since it is a Mozilla-based browser like Firefox. I also sugarized a little program called qxmp, a front end for mplayer. It works, but it has a problem similar to the one you described. When you click the frame icon, the program comes up quickly and operates normally, but the circle icon continues to blink. If you hold your cursor over it, it says "Starting .  . ." This icon blinks even after I quit qcmp, and I have to reboot Sugar in order to get it to stop. It doesn't seem to interfere with any other programs -- e.g., I can open a browser while qxmp continues to play music -- but it is certainly annoying.

If you want to try it, qxmp is here: http://www.xm1math.net/qxmp/index.html . You would also need to install mplayer.

Logged

#12 Re: How-to create a "stub/shortcut/launcher" Activity?

Karl L.
Contributor
*
Posts: 47


February 02, 2008, 07:38:23 PM

QXMP got me trying to sugarize too and it works, except for the starting thing.

I was looking around at all of the information here and I noticed that Albert Callahan uses a C program called sugarize for his own programs -- not the script used/suggested on the dev.laptop.org list.  I wonder if TuxPaint has these hanging problems. 

Can someone who knows C look at Callahan's sugarize.c script?  Perhaps then, the hanging start problem could be resolved.

Just a thought. . .

Karl
Logged

#13 Re: How-to create a "stub/shortcut/launcher" Activity?

CatMoran
Senior Contributor
**
Posts: 168


WWW
February 16, 2008, 09:55:11 AM

I tried to sugarize qxmp, and I'm getting the same result as everybody else.

Unlike the sugarizable apps (that I know of), qxmp also starts in Sugar as a small floating window, instead of occupying the whole screen. My guess is that it just doesn't have the same sort of window wrapper as those other apps. Putting another wrapper around it would probably fix it, but I don't have the first clue where to start.

In unrelated news, I won't be supporting or enhancing the script I wrote. These days I only boot into Sugar to play with a few things like TurtleArt; I've removed the few 'sugarized' icons I'd previously installed. (I boot into xfce the rest of the time.)

I will continue to host the files. And if anybody makes any upgrades to the script, I'd be happy to host those as well.
Logged

#14 Re: How-to create a "stub/shortcut/launcher" Activity?

Grampa
Senior Contributor
**
Posts: 170


February 24, 2008, 04:18:38 PM

For what it's worth, the activity ExecCommand works fine with qxmp. You click its icon in Sugar, it brings up a dialog box, and you enter the command "qxmp." This calls the program and cleans up after itself. There is one version on the Activities page of the wiki. The other, which may be the same, is here: http://wiki.laptop.org/go/ExecCommand. ExecCommand will not call Midnight Commander, however.

It's obviously a compromise, since you still need to enter the command, but it may be less intimidating to some than opening Terminal.
Logged
Pages: [1] 2 3 4
Print
Jump to:  

Welcome, Guest. Please login or register.
Did you miss your activation email?
February 08, 2010, 10:30:06 PM

Login with username, password and session length
Recent Topics
[February 06, 2010, 08:21:34 PM]

[February 06, 2010, 01:30:32 PM]

[February 06, 2010, 04:14:13 AM]

[February 05, 2010, 05:14:11 PM]

[February 05, 2010, 02:35:40 PM]

[February 04, 2010, 07:21:32 PM]

[February 04, 2010, 01:50:58 PM]

[February 02, 2010, 07:37:01 PM]

[February 02, 2010, 12:28:12 PM]

[February 02, 2010, 10:55:23 AM]
Members
Total Members: 4128
Latest: divinegrace29
Stats
Total Posts: 30200
Total Topics: 3647
Online Today: 82
Online Ever: 220
(February 05, 2009, 11:29:32 AM)
Users Online
Users: 0
Guests: 58
Total: 58