Notifier-Apps: Client/Server HTTP-based desktop notifications

There are the following components:

The client

A command line client written in Perl 5 that sends a message using HTTP and JSON to a URL hosting the server. E.g:

notifier notify --msg "Finished building the software project"

This can be used in shells using an idiom like:

make ; notifier notify --msg "Finished building the software project"

The server

An HTTP service, implemented using Dancer2 that listens for notifier events and invokes an event hook (such as a program displaying a video along with the notified message).

One should run it on the local desktop where one wishes to be notified of the events.

The event handler

The server can be configured to invoke any arbitrary command as an event handler for when a notification arrives. Previously I used to invoke kdialog or xmessage along with mpv but it was less than ideal.

As a result, I wrote a custom event handler using python-vlc and PySide2 / PyQt5 (largely derived from an example in the python-vlc repository) that can be invoked by the server. (I guess it is the ship of Theseus all over again.)

A forwarding service

As sometimes one sets up a client to connect to a port on a remote machine, and wishes to forward the request to the locally-running service, I decided to write a simple HTTP request forwarder. Several versions of it (written in Flask / Python, Node.js and Mojolicious / Perl 5 but otherwise equivalent in their functionality) can be found in the repository.

Protocol Spec

The client should make a GET request to the /notify endpoint of the service with the following query parameters:

  1. cmd_id - an optional key whose value is a UTF-8 string.

  2. text_params - A JSON key/value object encoded as UTF-8 and then GET encoding. Recognized keys are msg whose value is a text to display (instead of the default one).

Example using curl:

curl 'http://localhost:6300/notify?text_params=\{"msg":"Replacement%20Message"\}'

This assumes the service is at http://localhost:6300/ .