Skip to content

Instantly share code, notes, and snippets.

@stvnwrgs
Last active June 2, 2022 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stvnwrgs/2080a3fa5d43543b0638b5507958757f to your computer and use it in GitHub Desktop.
Save stvnwrgs/2080a3fa5d43543b0638b5507958757f to your computer and use it in GitHub Desktop.
A small script to send push notifications to your phone when a job is done
#! /bin/bash
#################### Usage
#
# 1. Register an account on https://www.pushbullet.com/
# 2. Add devices
# 3. Create an access token https://www.pushbullet.com/#settings/account
# 4. save it to your bash profile $PUSHBULLET_API_TOKEN
# 5. Re-source, Execute the following (you can remove jq):
#
# curl --header "Access-Token: $PUSHBULLET_API_TOKEN" \
# https://api.pushbullet.com/v2/devices |jq
#
# 6. Copy the device identifier you want to push on
# 7. Save it to you bash profile $PUSHBULLET_DEVICE_ID
#
# 8. Save this file in your executable path
#
# Now you can send a notification to you device when a command is finished
#
# For example:
# docker build -t example-command . && pushb "Build done"
#
echo "Sending notification"
RESULT=$(curl -s --header "Access-Token: $PUSHBULLET_API_TOKEN" \
--header "Content-Type: application/json" \
--data-binary "{\"body\":\"$1\",\"title\":\"pushb notification\",\"type\":\"note\",\"device_iden\":\"$PUSHBULLET_DEVICE_ID\"}" \
--request POST \
https://api.pushbullet.com/v2/pushes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment