NotifyThis 0.1: notify everything easily!

In our French ubuntu party organized by ubuntu-fr, we have approximately 20 free and ready to use computers for people to be able to try ubuntu on their own (we have someone around to help new users).

But that's a lot of wasted space for advertising our conferences, scheduled demonstrations, lessons we have during the party! So, the idea was to create a daemon notifying this, resulting in:

NotifyThis is here to fulfill this need. It's a desktop daemon (no pid file) using dbus for single instance and actions like pausing, stopping, forcing configuration file reload[1]

Source file is in XML (default in /etc/notifythis-data.xml):

 <?xml version="1.0" encoding="UTF-8"?>
<notiftypes>
<type>
<name>lesson</name>
<priority>low</priority>
<icon>/usr/share/icons/Humanity/apps/22/gnome-terminal.svg</icon>
</type>
<type>
<name>conference</name>
<priority>low</priority>
<icon>/usr/share/icons/Humanity/stock/22/stock_people.svg</icon>
</type>
<type>
<name>demos</name>
<priority>low</priority>
<icon>/usr/share/icons/Humanity/places/22/user-desktop.svg</icon>
</type>
<type>
<name>miscellaneous</name>
<priority>low</priority>
<icon>http://awesomeurl/dialog-warning.svg</icon>
</type>
</notiftypes>
<notifevents>
<event>
<title>Beginners lesson</title>
<content>Lesson for beginners in 10 min</content>
<type>lesson</type>
<time>2009-09-27 12:33</time>
</event>
<event>
<content>Advanced lesson starting in 15 min</content>
<type>lesson</type>
<icon>http://unexistingurl/stock_dialog-warning.svg</icon>
<time>2009-09-26 22:01</time>
</event>
<event>
<title>Awesome conference</title>
<content>An awesome conference on Ubuntu will start in 5 min.\nKeep it hot!</content>
<type>conference</type>
<time>2009-09-27 23:54</time>
</event>
<event>
<title>End of the event</title>
<content>Well… I guess you will have to leave NOW!</content>
<type>miscellaneous</type>
<icon>/usr/share/icons/Humanity/status/22/stock_dialog-warning.svg</icon>
<time>2009-09-27 23:55</time>
</event>
</notifevents>
</notifythis>

What can I do in this notifythis namespace?

You associate an event instance (in notifevents/event ) to a notifytypes/type/name declared in the file. Types enables you to set some default priorities and icons to events. <Icon> refers to a path to an icon, which can be local to your computer or distant served by your preferred web server (http://…). In the latter case, NT will cache it for you locally. Consequently, using multiple times the same icon in different types or events will download it only once.

Title is used as… notification title and content as… content :) <time> is used to specify when the event will be notified. Categorizing your event is just a way to avoid multiple icon/priority definitions, but those two values can be overridden for a particular event simply specifying corresponding tag (<icon> for instance). If it can't be found, event type icon will be shown. If this one doesn't exist/can't be reachable either, a warning is spawn in log file and no icon will be displayed.

So, you can for your event, but it can be bound with any kind of other things like calendar, TODO items, and so on…

But well, as unscheduled event changes may happen[2], you surely want to upload your xml file online and reload it in all NotifyThis daemon dynamically. It's possible too (and what we will do during our party).

In /etc/notifythis, you can set where the xml file is:

 # time in minutes beteen two xml file reloading, default is 30 minutes

# xml files (separated by ';') by order of preferences.
# It can an absolute or a relative path to this file.
# It can be a network path (http://) too
XML_FILES=notifythis-data.xml

You can even specify multiple XML_FILES and first found one will be use (like in XML_FILES=http://my/central/xml/file.xml; /usr/local/mybackupfile1.xml;notifythis-data.xml). XML file will be reloaded every \$DELTA_BETWEEN_XML_RELOAD min (30 min if not specified) in each daemon. If no xml file is found, previous working configuration is preserved and a retry is done every minutes then.

By default, NotifyThis is a desktop daemon[3] launched with a classical .desktop file in /etc/xdg/autostart/. Log are in ~/.local/share/notifythis/notifythis.log

Well, NT uses Quickly to simplify project handling. I guess we should investigate in a desktop-daemon template, making properly the double forking, using dbus instead of a pid file and dbus communication to reload configuration file, stop, pause… this can be handy! We can perhaps add a way for a template to reference another template to avoid redefining same commands twice and gives an easy way to call them (without having specifying --template ubuntu-project, for instance).

Well, if you want to give it a try, NotifyThis 0.1 is out and is available in my ppa.