2

I'm trying to create some webapps to use with Firefox. I got an tutorial from Canonical (http://developer.ubuntu.com/resources/app-developer-cookbook/unity/integrating-tumblr-to-your-desktop/) and I didn't understand one thing, maybe someone could help me.

I have to run the following script in Web Console:

// ==UserScript==
// @name          tumblr-unity-integration
// @include       https://tumblr.com/dashboard
// @version       @VERSION@
// @author        WebApps Team
// @require       utils.js
// ==/UserScript==

window.Unity = external.getUnityObject(1.0);

Unity.init({ name: "Tumblr",
            iconUrl: "icon://Tumblr",
            onInit: null });

Everything is fine, it created the icon launcher and work with alt+tab. That enough for me by now, but, if I close the windows, the launcher icon that I created before stop working (I mean, it open the site, but doesn't work like other webapp and doesn't show in alt+tab too). Maybe I have to run this script automatically every time I enter on that site (In this example, Tumblr). How can I do that?

Thanks,

2 Answers 2

3

Yes you are right. You need to execute that again.

Basically webapps are user scripts which are executed everytime you enter on a determined website (in your case, https://tumblr.com/dashboard), which then provides the integration the website on the Unity desktop.

So if you want to make that "permanent" (execute that code everytime you enter on the website), either you can include that js on the website (if you own it) or use something like GreaseMonkey or TamperMonkey to include that script on websites which you do not control.

Of course, you can also create a package: see the source of unity-webapps-youtube for example.

9
  • Thanks. Now I have two new -noob- questions: 1) How can I see the source of the unity-webapps-youtube 2) Where I can find more info about create my own package?
    – euDennis
    Mar 16, 2013 at 23:58
  • 1) apt-get source unity-webapps-youtube; 2) Here, but as in your case there is no need to compile anything, it should be a lot easier to just create a directory structure like unity-webapps-youtube and use dpkg. See here.
    – Salem
    Mar 17, 2013 at 0:18
  • My code worked in Firefox (Greasemonkey), but won't work in Chromium (Tampermonkey). Anyone know why?
    – euDennis
    Mar 29, 2013 at 17:37
  • I made my own unity-webapp using the source from unity-webapps-launchpad. The result is that: github.com/eudennis/unity-webapps-feedly After that, I made my .deb file, but didn't work yet. Do you know if I made something wrong?
    – euDennis
    Mar 29, 2013 at 19:18
  • One thing I notice in the sample script above is that two members are missing from the array passed to init(): "domain" and "homepage". So I think that argument should read:
    – monotasker
    Apr 11, 2013 at 19:39
0

Here's how to integrate the script into Ubuntu "properly," short of making an install package. I'm including at each stage the terminal commands to do what I describe. For the sake of generality this assumes you are integrating an app called "Mysite." (I'm giving more explicit instructions here than the op probably needs, but I want to make sure it's useful for those with less Linux mileage.)

  1. Create a subfolder for your app under the /usr/share/unity-webapps/userscripts/ directory. For consistency it's good to name your folder unity-webapps-.

    cd /usr/share/unity-webapps/userscripts
    sudo mkdir unity-webapps-mysite

  2. Move your integration script (with the user.js extension) to the directory you just created:

    sudo mv ~/somefolder/Mysite.user.js /usr/share/unity-webapps/userscripts/unity-webapps-mysite/

  3. Create a new file in that same directory called manifest.json:

    cd /usr/share/unity-webapps/userscripts/unity-webapps-mysite sudo touch manifest.json

  4. Open that manifest.json file in your favourite text editor:

    sudo nano manifest.json

  5. Add to that empty file the metadata required for webapp integration. This metadata should be based on the opening comments section of your integration script. Here is a basic boilerplate manifest file for our Mysite script:

    {"includes":["https://mysite.com/", "http://mysite.com/"],
    "requires":["utils.js"],
    "name":"Mysite",
    "scripts":["Mysite.user.js"],
    "maintainer":"Me ",
    "manifest-version":"1.0",
    "integration-version":"1.0",
    "package-name":"Mysite",
    "icons":{"128":"128/unity-webapps-mysite.png",
    "48":"48/unity-webapps-mysite.png", "52":"52/unity-webapps-mysite.png", "64":"64/unity-webapps-mysite.png"}, "domain":"mysite.com",
    "homepage":"https://mysite.com/",
    "license":"GPL-3"}

  6. Create a square icon for your app at least 128px by 128px and make resized copies that are 64x64, 52x52, and 48x48. (I just use gThumb image viewer for this. GIMP also works.) You need to give all of the files the same name (unity-webapps-mysite.png) so you may want to create separate folders for each one called "128" "64" "52" and "48" to keep the files straight.

  7. Copy these image files to the appropriate subfolders of the directory /usr/share/icons/unity-webapps-applications/apps. If you have the webapps package already installed these subfolders should already exist.

    sudo mv ~/somefolder/128/unity-webapps-mysite.png /usr/share/icons/unity-webapps-applications/apps/128/
    sudo mv ~/somefolder/64/unity-webapps-mysite.png /usr/share/icons/unity-webapps-applications/apps/64/
    sudo mv ~/somefolder/52/unity-webapps-mysite.png /usr/share/icons/unity-webapps-applications/apps/52/
    sudo mv ~/somefolder/48/unity-webapps-mysite.png /usr/share/icons/unity-webapps-applications/apps/48/

Your webapp should now be integrated into Unity! You should be able to find it be searching the applications lens of the Unity dash and then (if you want) pin it to your Unity launcher. It's possible that the icon won't be picked up immediately, but in that case just log out and log in again. Your webapp should now appear in all its iconic glory.

What I don't know is whether updates to the official unity-webapps-applications package will remove any of these files, so I'm working on figuring out how to package a script as a .deb and install it. But I'm unclear about that part. One way or the other you will want to make sure you have a backup of everything in your home folder just in case.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .