Blog is moving

My blog is moving to If you are looking for a specific or older post you are in the right place Otherwise check out my new page for more up to date content.

Friday, July 31, 2015

How to Send Pushbullet Notifications from Shell

If you use Pushbullet, you know how great the app is for notification. However you may not know that you can also use Pushbullet's API on your computer to send notifications. This comes pretty handy if you are running a script and wants to get some type of confirmation from it.
For example, I have a Raspberry Pi at home that I use for motion detection with IP cameras (with Motioneye). This server monitors Wifi clients and automatically disables the alerts when I'm home, and re-enables them when I leave. I use Pushbullet to get notifications when this happens.
To start, login to your account on Pushbullet and go to Settings.

You should see your "Access Token" on the bottom right (like the image below). Copy that as we will need it.

Now head to GitHub repo for pushbullet-bash and download the script.
Set your PushBullet API key by creating the file $HOME/.config/pushbullet and adding the linePB_API_KEY= with your "Access Token".
The script has the following options:
list - List all devices and contacts in your PushBullet account. (does not require
       additional parameters)
push - Push data to a device or contact. (the device name can simply be
       a unique part of the name that "list" returns)
pushes active - List your 'active' pushes (pushes that haven't been deleted).
delete $iden - Delete a specific push.
delete except $number - Delete all pushes except the last $number.
delete all - Delete all pushes.

To view your registered devices use the list option:

And to send a notification to a device, use the push note option. For example, here's how I would send a notification to my cellphone:
$ push "Note 4" note "$HOSTNAME" "Your script is complete"

No comments: