Send a Pushover notification from Linux

Push notifications are nothing new but they are an essential component of the modern technology landscape. They allow apps and services to send notifications to your mobile devices.

A few years I was looking for a way to improve my Python development skills but also for a way to 'announce' when a Linux system had booted. I wrote bootlace to solve this problem using Pushover.net.

Usage


To use bootlace you'll need Python installed as well as the contents of requirements.yaml.

git clone https://github.com/IronicBadger/bootlace.git
cd bootlace
pip install -r requirements.txt

Once installed, send a message using your Pushover API user and application tokens. For example:

python bootlace.py -m "Message content" -t "Application token" -u "Pushover user token" -d "Override device name" -T "Override notification title"

Pushover Tokens


Two tokens are required to use the Pushover API. The first is an application specific token. Begin by clicking Create an Application/API token.

Next, fill out the information you want to provide for the application and find yourself a nice icon.

Then copy your application API Token/Key for use by bootlace.

Finally, on the main page take note of your User Key.

Configure bootlace to run at reboot


Using cron we can run bootlace when the server reboots. First create a simple shell script to execute bootlace and save it as bootlace.sh somewhere. This example uses /home/alex/bootlace.sh.

#!/bin/bash

/usr/bin/python3 /home/alex/scripts/bootlace/bootlace.py -m "server booted" -t apptoken -u usertoken

Then add the task to cron.

@reboot /bin/bash /home/alex/bootlace.sh > /dev/null 2>&1

Then, reboot the server and...

Wrap-up


I've used bootlace for 6 years at this point for my own needs. However when writing this article I noticed that Pushover now provide examples for calling their API via curl and numerous other means. If you'd prefer not to have Python, you have another option!

Good luck and please feel free to ask any questions over on Discord at https://selfhosted.show/discord. I'm there as @alexktz and on Twitter @IronicBadger.

Another interesting option that @Roxedus just made me aware of over on Discord is Apprise. A single interface for multiple notification services.

Consider giving my podcast a listen over at selfhosted.show if you found this interesting. Thanks!