Runnable styles are just that - styles which Snarl 'runs' in order to generate content which can then be displayed as a notification. The style has full control over the look of the content (including the size and shape); Snarl retains control over where the content is displayed. Consequently, runnable styles offer a happy medium between ease of creation and control over the resulting content.
A runnable style must provide the following:
All of the above must exist within a folder named using the following convention:
Ultimately, the folder naming convention is there to ensure two styles with the same name but from different vendors do not compete for the same folder name. The following are examples of acceptable folder names:
The configuration file (runnable.conf) is a standard text file which can be created using any suitable editor. It should consist of a [general] section and an optional [schemes] section.
Only some settings are mandatory - the following table describes the settings supported, what they do, and indicates whether they are required or not:
Available schemes should be listed as they are expected to appear to the user (that is, with the required upper and lowercase).
description=Just a simple demonstration...
The supplied icon.png should conform to the following:
Style creation is the job of the style executable. The executable can be a standard Windows executable file, or it can be a script file which Windows is able to execute indirectly (e.g. via knowledge of the extension) so something like style.vbs would work fine under most conditions.
In order to generate suitable content, the style executable must:
Failure to do any of the above will result in Snarl rejecting the generated content. The notification will still be displayed however, only using Snarl's own internal style.
Note: If the style has indicated that it is a redirect (by setting the appropriate value in runnable.conf) then the style must still create a content.png file, however this file may be zero bytes (and, thus, not a genuine PNG image).
Snarl communicates with the style executable in two ways:
If Snarl needs the style to do something other than create its graphical content, the first argument will be preceded with a minus sign ('-') for example:
Is Snarl's way of asking the style to display its user interface.
In these cases the style should handle the command silently (even if it doesn't support the command) and not generate any image content.
If the argument does not begin with a minus sign, then Snarl is asking the style to generate updated graphical content and the argument will be the originating API request which Snarl received.
In addition to the mandatory requirements for the style executable, developers should also note the following:
Once completed, you should create a zip of the folder containing your style. You must ensure the folder path structure is preserved inside the zip file, as follows:
Finally, you should rename the zip file so that it has a '.rsz' extension. Snarl users can then double-click the file or drag it onto Snarl's Preferences panel in order to install it.
This example uses VBscript to create a very simple redirect style which simply logs notifications to a text file. Error detection, actually doing something useful with the notification content, and so on are all left to the developer as further work.
The first thing to do is create the required folder structure:
Now we need to populate the runnable.conf file:
Now we need to create the style executable. For this example style, we'll use a simple VBscript:
Dim oSh, oFSO, oArgs, oFile
set oSh = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile(oSh.CurrentDirectory & "\log.txt", 8, True)
Set oArgs = Wscript.Arguments
If oArgs.Count > 0 then _
Set oArgs = Nothing
Set oFile = Nothing
Set oFSO = Nothing
Set oSh = Nothing
To test the style, the runnable style engine will need to be stopped and restarted. To do this:
To verify that the test worked successfully, navigate to the acme-logger folder you created at the start of the example and open the log.txt file.