Irssi notifications on iOS and Android

Christian Kjær in a casual setting :)
Christian Kjær
2 min read

·

25. September 2014

·

Or really anywhere that https://pushover.net supports.

In light of the earlier article, I thought I'd might as well supercharge my IRC setup. So, now we're gonna get some notifications for our mobile devices via pushover.

Setting up pushover

There really isn't much to do here. First, go create an account and download the app on the device you want notifications on.

Then, register a pushover application. You can do this from the dashboard, or directly from https://pushover.net/apps/build. It will look something like this,

Pushover Application Registration

Setting up the script

So, like the article mentioned before, I'm assuming you're using irssi and the fnotify plugin.

Create a file called something like irssi_pushover.sh with the contents below,

irssi_pushover.sh
1#!/bin/bash
2
3# Replace `YOUR_APP_TOKEN` and `YOUR_USER_TOKEN` with your values from pushover
4tail -f /home/user/.irssi/fnotify | while read heading message; do
5 url=`echo "${message}" | grep -Eo 'https?://[^ >]+' | head -1`;
6 if [ ! "$url" ]; then
7 curl -s \
8 --form-string "token=YOUR_APP_TOKEN" \
9 --form-string "user=YOUR_USER_TOKEN" \
10 --form-string "message=${message}" \
11 --form-string "title=${heading}" \
12 https://api.pushover.net/1/messages.json
13 else
14 curl -s \
15 --form-string "token=YOUR_APP_TOKEN" \
16 --form-string "user=YOUR_USER_TOKEN" \
17 --form-string "message=${message}" \
18 --form-string "title=${heading}" \
19 --form-string "url=${url}" \
20 https://api.pushover.net/1/messages.json
21 fi;
22done;

This script will read from /home/user/.irssi/fnotify and send a POST request with the message and title via curl using the pushover API.

You need to change the destination to the correct location of your fnotify file, and of course also replace YOUR_APP_TOKEN and YOUR_USER_TOKEN with your values from pushover (the user token is on the dashboard and the app token is under the app).

Conclusion

Now you've got notifications on your phone too! :) Never miss a moment of IRC again. A tip: you can make pushover open links directly to the browser under settings in the app.