Skip to content

Instantly share code, notes, and snippets.

@erickbrower
Last active December 14, 2015 06:39
Show Gist options
  • Save erickbrower/5044675 to your computer and use it in GitHub Desktop.
Save erickbrower/5044675 to your computer and use it in GitHub Desktop.

Chat Like a Hacker: Command Line Gtalk with OTR and iOS Push Notifications

MCabber Screenshot

My workflow nowadays involves a lot of time at the shell. I've recently become a disciple of Unix as an IDE, so over time I've replaced my GUI-based dev tools with their shell-based counterparts. Sublime Text with vintage mode was quickly dumped for Vim and a few plugins. Tabs in gnome-terminal were replaced with tmux (and somewhere, a choir of angels burst into song) hosting tons of ssh or psql connections. If I don't need to look anything up online, I can work for at least a couple of hours before coming up for air at the desktop.

So naturally I started thinking about a shell-based replacement for chat. My go-to solution has always been Pidgin for its simplicity, plugins, and OTR (Off The Record) encryption support. I strictly use gtalk, so the client wouldn't need to support multiple protocols. I wanted something simple to use and easy to configure. Give me a tool that can do 5 things really well over one that can do 50 things half-assed.

I chose MCabber. It's lightweight, fast, and configured via *rc file. It works out of the box with OTR, and everything down to the colors and keybindings are configurable. I was sold within 15 minutes of installing it.

There was just one problem though -- notifications. If I was actually looking at MCabber, incoming chats were obvious. But if I tmux'ed away or got caught up reading an article, I'd miss them. Digging into the mcabberrc file, I noticed a configurable external hook -- a script that's triggered on client events. So any time someone signs on or, more important for me, when he sends me a new message, the script is run with some relevant arguments passed to it. It could also be configured to only respond to events when MCabber isn't the current window. Perfect! On my gnome desktop, I can use libnotify to get fancy popup notifications in the OS. But what if I want to run MCabber on a VPS or something?

I always have my iPhone with me, so why not send a push notification to my phone? There's an app for iOS called Prowl, currently $2.99, that works with their email service to essentially forward emails to your iPhone as push notifications. After signing up, you can generate an email address to be used for your notifications. Send any email to that address, get it as a push notification on your iPhone. Worth every penny of $2.99, IMO.

Want encrypted command-line chat that routes notifications to your iPhone? Then let's kick this ish off:

Installing and Configuring MCabber

  1. I'm on Arch linux, so installing mcabber was as easy as pacman -S mcabber. Hopefully it's as straightforward for your distro.
  2. Create a directory for your mcabberrc and eventcmd files. mkdir ~/.mcabber .
  3. Grab a copy of my example mcabberrc and save it to ~/.mcabber/mcabberrc. It's already configured to use the eventcmd script for notifications.
  4. Add your gmail credentials to the mcabberrc. If you want to be prompted for your password (recommended), leave "set password" commented.
  5. Run mcabber and verify that it's connecting properly.

Notifications for New Messages

If you've got libnotify handy and just want local notifications, you can use this eventcmd script. If you want to use Prowl and get push notifications instead, use this script. The second script uses google's own gmail servers to send the email, so you'll need to plug in your gmail creds along with your Prowl API email address. Save either to ~/.mcabber/eventcmd. If you want to verify that the eventcmd script is ready to go, run the command ~/.mcabber/eventcmd MSG IN somebody@gmail.com to send a test notification.

And there you have it. Oh, and be sure to check out the MCabber FAQ. If you have any suggestions or if I'm doing something silly, feel free to comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment