// you’re reading...

Google

Push custom notifications to your Android Watch from Linux command line or scripts

I had gifted an LG G Watch to my wife in December. She used it religiously for several months. Some time back, she started forgetting to charge it or wearing it to work. I found this the right opportunity to grab it and use it with my Moto G Android phone. So far (after a couple of days of using it), I find the watch quite useful while driving. That’s when I can just glance through the notifications without looking at the phone or taking it out from my jeans pocket.

Custom notification sent from Linux to Android Watch

Custom notification sent from Linux to Android Watch

At night, it is useful to have the watch by the bed side while the phone is changing elsewhere at home. Depending on the notifications (email, SMS or call) on the watch, I can decide if I want to get out of the bed to attend it on the phone.But what’s more?

So I started searching for new apps and use cases that will keep me interested in a wrist watch – this is the first time I’m wearing a wrist watch in the last 12-13 years. From the above, it is clear that notifications is a strong feature of a smart watch. So what if I could trigger custom notifications to it? This idea occurred to me when last night I was importing a big MySQL database. What if I could send a notification to the watch once the import had finished? Do I need to write my own Android Wear app for it? Not really! Thanks to Pushbullet.

To get started, go to http://www.pushbullet.com. Sign in with your Google/Facebook account. I used my Google/Gmail account. Once signed in, click on your profile photo (top right) and then select Account Settings. Copy or note down the Access Token. This will be used to send notification.

Next, install the Pushbullet app on the Android phone. Launch the app and on the first screen sign in with the same account (Google account in my case), that you used to sign in at pushbullet.com. On the subsequent screen, click on Notification access. Assuming that your phone is already paired with an Android watch, Android Wear will show up on the next screen. Make sure it is ticked/selected. That’s it.

Note that Pushbullet will work even if you do not have an Android Wear device/watch. In this case it will still send notifications to the phone.

Now sending a notification via Pushbullet from a Linux command line can be done as follows:

curl --header 'Authorization: Bearer <access-token>' -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "<title>", "body": "<body>"}'

Pushbullet provides a REST API to send notifications. So all you need is curl which can be installed via the command ‘yum install curl’ on RedHat, Fedora or CentOS.

In the above command, replace <access-token> with the access token that you noted down on the Pushbullet website after signing in (see above). Replace <title> and <body> with a title and message for the notification. For example, I used the following command to send me a notification when the database import was done:

mysql -u root -psecret mydb < data.sql;
curl --header 'Authorization: Bearer xt6wcjiFJsmUogSOpXrwv30uOolk314t' -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "DB Import Status", "body": "The database import has finished."}'

In the above command, once the database restore has completed, the curl command is fired to send a notification. Note that the two commands are separated by a semicolon. The access token I used in the above command is modified to not reveal my real access token and will result in an error saying “Access token is missing or invalid”. So substitute it with your access token.

The above is just an, one, simple example. One can send notifications to an Android Watch through monitoring software like monit, cron jobs and even web applications, thanks to Pushbullet’s REST API.

At home, I’m running a torrent server powered by Transmission torrent client on Linux. The server has transmission-daemon installed which provides a web based interface to add or manage the torrents. One nifty feature of transmission-daemon is, it can be configured to execute a command when a torrent download has finished. I have been using this feature to send me an email notification when a download has finished. Now, in addition to email, I have set it up to send me a notification on my watch. Time to watch a movie!

 

 

 

GD Star Rating
loading...
GD Star Rating
loading...
Push custom notifications to your Android Watch from Linux command line or scripts, 5.5 out of 10 based on 2 ratings
Share

Email This Post Email This Post Print This Post Print This Post Print This Post Post A Comment Tweet your comments/question to me @shekharg

Discussion

4 comments for “Push custom notifications to your Android Watch from Linux command line or scripts”

  1. RT @shekharg: New Blog Post: Push custom notifications to your Android Watch from Linux command line or scripts – http://t.co/O9QNdqzOuc

    Posted by sharat_j | April 6, 2015, 11:14 pm
  2. RT @shekharg: New Blog Post: Push custom notifications to your Android Watch from Linux command line or scripts – http://t.co/O9QNdqzOuc

    Posted by pankaj_shukla | April 6, 2015, 11:44 pm
  3. […] Push custom notifications to your Android Watch from Linux command line or scripts | Shekhar Govinda… […]

    Posted by 利用 Pushbullet、Twitter 做提醒通知 « Jamyy's Weblog | August 14, 2015, 2:02 pm
  4. I run transmission on Linux. What you have is what I want. I just wish there was a guide.

    Know of any? Or can you provide instructions. I’m a bit of a novice.

    Thanks,
    Matt

    Posted by Matt | January 26, 2016, 12:15 am

Post a comment

Recent Tweets

Follow Me on Twitter