Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 5 down vote accepted

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:

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["        <li><a href=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2014 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2014.7.25.1726\r\n            </div>\r\n                <div id=\"additional-notices\">\r\n                    Ubuntu and Canonical are registered trademarks of Canonical Ltd.\r\n                </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-wa"], "copyright__copyright__copyright": ["as some simple example lenses written in python and Vala.\n\nAs far as I know it's not (yet?) possible to write lenses in PHP.\n\nshare|improve this answer\n\nThere are a bunch of tutorials in the Ubuntu Lens wiki. The easiest I think is one I found on a blog here.\n\nHere is the wiki.\n\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}