You can connect to the activate-uri signal to perform actions on a result displayed in a lens.
First, you need to connect the activate-uri signal in the Daemon's init function (where you connect the search-changed and filters-changed)
self.scope.connect ("activate-uri", self.activate_uri)
Then, create a activate_uri function in the Daemon.
def activate_uri(self, scope, uri):
#Do stuff with uri here
return Unity.ActivationResponse (handled = Unity.HandledType.HIDE_DASH, goto_uri = '')
This function takes the scope object and the url parameter from the result. url does not necessarily need to be a uri, but must be text. You can do whatever you want with the text in the function. At the end of the function, you need to return the Unity.ActivationResponse as detailed above in order to close the dash.
Have a look at http://bazaar.launchpad.net/~markjtully/+junk/calendar-lens/view/30/calendar-lens-daemon.py line 101 & 274-296 for an example of this in action.
Using Quickly or unity-singlet
With quickly, it is even easier: Add a function
def handle_uri(self, scope, uri):
# Do stuff with the uri here
to your lens class (in __init__.py). It will be automatically connected to the signal, you do not have to take care of this. Don't forget to add from gi.repository import Unity to your import statements.