Growl Tools

By PhasmaExMachina Last update Sep 22, 2009 — Installed 10,862 times. Daily Installs: 87, 91, 276, 407, 207, 156, 106, 164, 195, 119, 120, 119, 122, 179, 268, 227, 147, 113, 114, 141, 162, 131, 287, 420, 386, 423, 424, 438, 213, 226, 207, 134
Script Summary:
Tool for use in your scripts to allow for dead simple use of the Growl notification program.
Version: 0.01
Recently Updated TopicsPosts
Using this script?1

this script has 1 topic, 1 post

This script has no reviews.

 

Do not install. See "Usage" section below.

If you want to see this in action, check out this demo.

Credits & Introduction

Much of this code is the work of Brian Dunnington and can be found here. I just put it all together an interface to make it even faster to set up and use.

This script is intended to be included in your own scripts through the @require meta tag.

Requirements

In order to see Growl notices using this method, you will need to have installed the following:

  1. Firefox
  2. Greasemonkey add-on for Firefox
  3. Growl/GNTP add-on for Firefox
  4. Growl for Windows (direct download) or a development build of Growl for OSX

Setup: (you only have to do this once)

  1. Install Growl for Windows (direct download) or a development build of Growl for OSX
  2. Start Growl. You may want to open Growl once it starts and turn on auto start.
  3. Install Growl/GNTP add-on for Firefox
  4. Restart Firefox
  5. Go to the Ikariam Options page and scroll down to the Ikariam Notifier section
  6. Click on "test" next to the Growl section and you should see a test notification pop up.
  7. Customize the notification settings under "Applications" and "Displays" in Growl if desired

Usage

  1. Include this script
  2. Declare notice types
  3. Register with growler add-on
  4. Send notices

Step 1 - Include this script

In order to use this tool in your scripts, you must include it within your //==UserScript== block as follows:

// @require http://userscripts.org/scripts/source/58203.user.js

Note: this scripts will [em]only[/em] be downloaded when you install your script. Just adding the line above without re-installing your script will do nothing. For more information, read about the @require meta tag.

Step 2 - Declare notice types

To actually use the growler, you must declare at least one notice type using Growl.addNoticeType(typeName, name, enabled). For example:

Growler.addNoticeType("attack", "Enemy Attack");

The last parameter (enabled) is optional, and defaults to true.

The reason for declaring notice types is so that the end user can change his or her growl settings for each event type (e.g. how long each notice stays up, whether or not to play a sound, etc.)

Step 3 - Register with the growl add-on

The grown application needs to be told about your script and what kinds of events you are using. This needs to happen on every page load before you can actually send notices. To register with the grows add-on, use the Growl.register(appName, iconSrc) method. For example:

Growler.register('My Super Script', 'http://pathto.com/myicon.png');

The second iconSrc parameter is not required, but is always a nice touch. Whatever icon you specify will be displayed next to all notices from your script.

Step 3 - Send notices

The last step is sending actual notices to growl. This is done through the Growler.growl(typeKey, title, message) method, which should be called whenever you need to send a notice for whatever reason. Here's an example that puts it all together.

Growler.addNoticeType('greeting', 'Greeting from Hal');
Growler.addNoticeType('question', 'Question from Hal');
Growler.register('HAL 9000 Script', 'http://i763.photobucket.com/albums/xx278/PhasmaExMachina/icons/hal_icon.png');
Growler.growl('greeting', 'Hal 9000', 'Hello Dave.');
setTimeout(function() {
    Growler.growl('question', 'Hal 9000', 'What are you doing Dave?');
}, 5000);

The code above will result in the following application being added to the Growl application tab and the following 2 growl notices: