Tutorial: Sending notifications from other platforms to Snarl

This tutorial explains how to send notifications to Snarl from various different platforms, such as Raspberry Pi, using the Python-based snp-send tool.

pi

To get started you will need:

Step 1: Getting started

Firstly, make sure Snarl is installed and running and it is listening for incoming SNP 3.0 notifications on port 9887 (this tutorial assumes port 9887; you can use any available port).  See this tutorial for help on getting Snarl listening for notifications.

Step 2: Configuring Python

Your notification source must be running Python 3.2 or later (snp-send may work on earlier versions of Python 3; it just hasn’t been tested on them – it will not work on Python 2.x).  Installation on some common platforms is as follows:

Raspberry Pi

Raspbian includes Python 3.2 so you’re good to go!

Debian 7

Install Python 3.2 (or any later version) as follows:

  • Launch a terminal
  • sudo as root
  • Run apt-get install python3.2
  • Follow the prompts
  • Exit back to your user session
OS X and Windows

Download and install the latest Python 3 release and follow the installation wizard.

Step 3: Installing snp-send

Download snp-send 0.5 (or later) and unzip into an easily accessible location, such as your home folder.

Step 4: Testing snp-send

Launch a terminal, navigate to where you installed snp-send and enter the following:

python3.2 snp-send.py -d 192.168.1.1 -b ‘Hello, world’

If you’ve installed a newer version of python, you should substitute “python3.2” with the correct version number.  Also, note that the IP address after the -d parameter should be the IP address of the machine running Snarl.

You should see the following displayed:

snp-send: connecting to 192.168.1.1:9887...connected!
snp-send: notification sent

And a corresponding notification on the machine running Snarl.

Debian 7 Wheezy
Debian 7 Wheezy

 

Raspbian
Raspbian

Step 5: More features

snp-send is quite sophisticated.  To see all the different options it supports, enter the following in the terminal:

python3.2 snp-send.py -?

Now, let’s add an icon:

python3.2 snp-send.py -d 192.168.1.1 -b ‘Hello, world’ -i ‘!system-info’

And a sound:

python3.2 snp-send.py -d 192.168.1.1 -b ‘Hello, world’ -i ‘!system-info’ -n ‘!windowslogon’

And make it sticky:

python3.2 snp-send.py -d 192.168.1.1 -b ‘Hello, world’ -i ‘!system-info’ -n ‘!windowslogon’ -s

snp-send assumes port 9887 if one isn’t specified.  However, if Snarl is listening on another port on the remote computer, you can direct snp-send to use that with the -p switch, as follows:

python3.2 snp-send.py -d 192.168.1.1 -p 4444 -b ‘Hello, world’ -i ‘!system-info’ -n ‘!windowslogon’ -s

Have fun!