5x12 pentomino tiling
«

Pushbullet from the Shell

»

This is just Google fodder so if you don't have an Android device, Linux and (possibly) a Pebble watch1 then you probably want to move on.

Hello world via Pushbullet on my Pebble Pushbullet is a wonderful thing. Essentially it gives you a mechanism to share ("push") links, files and text across your devices, where "devices" in this context are Android devices2 and your desktop web browsers. So, for example, I can push a photo from my phone's gallery to my desktop copy of Firefox3, or I can open a link in Firefox on my desktop and push it across to the browser in my tablet. It's an elegant thing, I find it especially useful for copying over long URLs for setting up apps on my phone.

Anyway, I now have a Pebble watch, so it occurred to me that I could get system messages pushed to me, without the delay of up to 15 minutes which I get currently using SMS using IFTTT.

This, it turns out, is very simple. Here's how you do it. First you need your access token which you get from your Pushbullet account settings page (you'll need to be logged in natch). You get a long token, let's call it <Token>.

Next you need to know the ident of the device you want to send pushes too. You get that using curl thus:

curl --header 'Authorization: Bearer <Token>' -X GET https://api.pushbullet.com/v2/devices

That returns you JSON style result which itemizes all your devices. Find the device you want to message, in my case that's:

"nickname":"Motorola Moto ","manufacturer":"motorola","model":"XT1033"

and then you're looking for the iden for that device, another long string; let's call that <Iden>.

So now you're ready to party. Here's my script bullet (with <Token> and <Iden> replaced as appropriate):

#!/bin/bash # # Send a message, via pushbullet, to Paul's phone # TITLE=$USER@`hostname`
curl -s --header 'Authorization: Bearer <Token>' -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "'$TITLE'", "body": "'"$*"'", "device_iden": "<Iden>"}' > /dev/null

And now, when I type bullet Hello world then, within a few seconds, my phone gets that message pushed to it and on my Pebble I get what you see above. I can then clear that notification from my watch, which also clears it on my phone, so I don't have to take the phone out of my pocket.

As you can imagine I'd going to be bolting this into all my monitoring scripts.

  1. About which I will have (much) more to say later.
  2. I believe it works for iOS too if you're on the other side of the fence.
  3. Incidentally that's how I got that photo, which I'd taken with my phone, onto my PC and I then saved it to my local hard drive for editing before uploading to the CMS I'm using here.

Tags: Android, linux Written 16/07/15

Comment on this article

«
You can follow these posts on Twitter at @Wibblings
»
I am currently reading:

Dark Suits and Sad Songs by Denzil Meyrick The Finest Road in the World: The Story of Travel and Transport in the Scottish Highlands by James Miller

(?)
Word of the Day:
ultramundane