Actions are currently undergoing a facelift in Snarl 3.1 so I thought it would make sense to explain a bit about how they work.

Any notification you create can have actions assigned to it and actions can be static (that is, they launch a file, folder or URL) or dynamic (Snarl notifies your application when the user picks a particular action from the menu).  Static actions are ideal for routing users to web pages for example, and they also work from non-persistent environments such as scripts and command prompts; dynamic actions offer more flexibility but need a persistent entity to reply back to.

Although actions can be retrospectively added to a notification, that method is now deprecated.  Instead, actions should be added to a notification when it is first created.  Any number of actions can be created and each action comprises two components – the label and the command – separated by a comma.  Let’s create a sample application to show this working – I’ll use the heysnarl tool as it allows you to see the raw request in full.

First, let’s register will Snarl:

heysnarl "register?app-sig=test&app-title=Test&keep-alive=1"

We use the keep-alive argument here to stop Snarl removing the application during its garbage collection sweep.  Other than that, this is about as minimal as you can get…

Next, let’s create a notification with a single action:

heysnarl "notify?app-sig=test&title=Hello&action=Link,"

If all goes well you should see something like this (note the globe icon is new to R3.1):

A simple URL action

Clicking the Link item should open your default browser targeted on

Next, we’ll add a link to a folder:

heysnarl "notify?app-sig=test&title=Hello&action=Link,,c:\"

And, lastly, we’ll put some separators and an info item in-between – note that these options are only available in Snarl 3.1 (currently in Beta):

heysnarl "notify?app-sig=test&title=Hello&action=Link,,!sep&action=Demo,!info&action=,!sep&action=Folder,c:\"

Loads of actions

So, there you have it: a very simple, yet very powerful way to extend the functionality of even the most simple notifications.


Categories: Tutorials

Leave a Reply