Saturday, December 15, 2012

Push notification + Terminal = Win!

Developing with Pushover

I was compiling ruby on my new Raspberry Pi (a process that takes about 2 hours) and I thought to myself, wouldn't it be great if I had some way of knowing when it was done? Wouldn't it be even more awesome if I could get info about any task in my terminal completing wherever I was?

I decided to give Pushover (https://pushover.net/) a spin during a late night hacking session. Pushover is essentially a (paid) app that allows you to receive push notifications on your phone through their simple API.

I was quickly able to hack together a bash/ruby function that I think will be pretty useful for me given how much time I spend in the terminal.

usage example: 
>sleep 2 ; notify "I slept for 2 seconds and woke up!"

The result (after ~2 seconds):

One could easily imagine kicking off a sereis of lengthy operations in the terminal, interspersing a couple of calls to notify, then going for a coffee until your phone says its all over. 
Ex: ./build_code.sh ; notify "Build complete" ; ./deploy_to_server ; notify "deploy complete, come back!" 

If this sounds interesting, follow the steps below to get setup:

1- First, you'll need to get the Pushover app for iOS or Android. It's not free, so you'l need to deal with that. Once you've download the app, create an account on your phone.

2- Go to their site(https://pushover.net/) and login. Once logged in, you'll see your user key in the dashboard. Note that down. 
3- You should have the option of creating a new application. Go through their application creation flow
4- Once you create the application, you'll get an application API token:
5- The last step is to add the following code to the end of your ~/.bashrc (or ~/.zshrc if you like to live on the edge). NOTE: replace application token with data from #4 and user key with data from #2.

Thats it! Now go kick off a build and wait for a pleasant ring to bring you back.

5 comments:

  1. I can see that you are genuinely passionate about this! I am trying to build my own website and you’ve helped me with some great information on what to implement on the main page of my site.

    ReplyDelete