A Little GUI for Your CLI
I've tried pretty much every IRC client available for both Linux and OS X. (I use both platforms during my day job.) No matter how many times I try to find a GUI application that meets my needs, I always turn back to Irssi. It works so well, and I can access it from anywhere (Figure 1). Thanks to my Raspberry Pi colocation in Austria, I always can stay logged in and never miss a message. Unfortunately, the one thing I wish Irssi had is a pop-up notification when someone sends me a message or mentions me in a channel. So, I decided to give Irssi a little GUI. It was fun, and as it turns out, it works very well.
Figure 1. I actually had to scroll up a bit to find something harmless enough to post in the magazine!
If you're running Irssi locally on the Linux machine you're sitting in front of, this process is much simpler. Since my Irssi-connected machine is on another continent, the process is a little more complex, but also a lot more fun. In order to get local GUI notifications for remote mentions of my user name, I need to accomplish a few things:
I have to get Irssi to generate some sort of event and/or log when I'm mentioned in an IRC channel or query.
I have to parse that information and transfer it to my local machine over the Internet in real time.
I need to display a GUI pop-up on my local machine when the remote events occur, again in real time.
I need to be able to disconnect and reconnect to a screen session and have the GUI notifications follow me, regardless of what computer I'm actually on. (In my case, this means Linux or OS X.)
Thankfully, Linux supplies all the tools I need, and with a little bit of scripting, I can get the system working.
Step 1: Irssi Events
I'm obviously not the first person to want a GUI notification system for Irssi, and thankfully, Thorsten Leemhuis has shared his Irssi plugin for everyone to use. You can download the plugin at http://www.leemhuis.info/files/fnotify/fnotify, and since it's released under the GPL, you can share it as you see fit.
In order to use the script, save it as fnotify.pl in your ~/.irssi/scripts/ folder where Irssi is running. For me, that's on my remote server in Austria. Once saved, you can load the script by typing:
/script load fnotify.pl
from inside the Irssi application. If you want to make fnotify.pl be loaded automatically every time Irssi starts (my recommendation), create a symbolic link into the autorun folder inside the scripts folder. To do that, type:
mkdir ~/.irssi/scripts/autorun (if it doesn't exist already) ln -s ~/.irssi/scripts/fnotify.pl ↪~/.irssi/scripts/autorun/fnotify.pl
Then fnotify should be loaded every time Irssi starts. To make sure it's working correctly, have someone mention you in an IRC channel, and check to see that the message is written to the file ~/.irssi/fnotify.
Once you're certain the plugin is working, and mentions of your name are written to the fnotify file, it's time to get that information to your local computer. But first, you need to set up the local computer for GUI pop-up messages, so you have somewhere to send the information when you transfer it.
A Local GUI Notification
This part of the equation is fairly simple. Most Linux distributions come
with a notification system of some sort. I prefer a GNOME environment,
so I choose to use libnotify, or more specifically the
command that creates a GUI pop-up when invoked from the command line
or from a script. KDE users can use the
kdialog program for a similar
effect, and OS X users will want to check out Terminal Notifier, hosted
From your Linux command line, test
notify-send by typing:
notify-send "Test Title" "Sample message..."
That should bring up a libnotify box with your title and message (Figure 2). If you're using KDE (or OS X), the command will be similar, but you'll need to check for the exact syntax. It's also possible to tweak the program to get custom icons, change the duration of the pop-up and even change the system urgency for the notification. I actually use a Pidgin icon for the notification box, only because I've used Pidgin for so long, the icon makes me think chat.
Figure 2. The pop-up system is really pretty slick.
Webinar: 8 Signs You’re Beyond Cron
11am CDT, April 29th
Join Linux Journal and Pat Cameron, Director of Automation Technology at HelpSystems, as they discuss the eight primary advantages of moving beyond cron job scheduling. In this webinar, you’ll learn about integrating cron with an enterprise scheduler.Join us!
- Tips for Optimizing Linux Memory Usage
- Picking Out the Nouns
- "No Reboot" Kernel Patching - And Why You Should Care
- DevOps: Better Than the Sum of Its Parts
- Return of the Mac
- Android Candy: Intercoms
- Drupageddon: SQL Injection, Database Abstraction and Hundreds of Thousands of Web Sites
- Non-Linux FOSS: .NET?
- Consent That Goes Both Ways