8

I'd like to create a custom scope that searches and returns results from an online source for personal use.

Is this possible? And if so, how?

0

4 Answers 4

10

For development in python:

Update for 12.04:

Unity lens development with singlet has been integrated into quickly:

quickly create unity-lens <lens-name>

For 11.10:

You might want to look at a very nice wrapper class developed by Michael Hall called singlet: https://launchpad.net/singlet

A simple hello world lens would look like this:

#! /usr/bin/python
from singlet.lens import SingleScopeLens, IconViewCategory
from singlet.utils import run_lens

class HelloWorldLens(SingleScopeLens):
    class Meta:
        name = 'helloworld'

    cat1 = IconViewCategory("Cat One", "stock_yet")

    def search(self, phrase, results):
        results.append('http://google.com/search?q=%s' % phrase,
                             'file',
                             self.cat1,
                             "text/html",
                             phrase, phrase, '')
if __name__ == "__main__":
    import sys
    run_lens(HelloLens, sys.argv)

Which is a lot simpler and faster to write than the original library versions.

5

Yes it is absolutely possible and really easy to create new scopes. The Ubuntu App Developer site has lots of content to get you started writing scopes:

2

The Ubuntu Wiki has a tutorial on how to write a Lens that uses Vala. Saravanan Thirumuruganathan wrote one for Python. The Unity Sample Place has some simple example lenses written in python and Vala.

As far as I know it's not (yet?) possible to write lenses in PHP.

2
  • There are GObject bindings for PHP (github.com/indeyets/gobject-for-php), so it should be possible, although learning python might be easier than making them work.
    – cscarney
    Dec 10, 2011 at 18:33
  • Please note that the linked python tutorial uses old API, the one on Ubuntu wiki is up-to-date.
    – mhr3
    Dec 21, 2011 at 16:44
1

There are a bunch of tutorials in the Ubuntu Lens wiki. The easiest I think is one I found on a blog here.

Here is the wiki.

2
  • These are basically the links given in the question. How is this helping?
    – xubuntix
    May 11, 2012 at 7:48
  • the blog link is not in the question May 11, 2012 at 13:11

You must log in to answer this question.

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