Skip to content

Instantly share code, notes, and snippets.

@KonradIT
Last active October 20, 2021 12:40
Show Gist options
  • Save KonradIT/8cab370f7ab3848c62ca to your computer and use it in GitHub Desktop.
Save KonradIT/8cab370f7ab3848c62ca to your computer and use it in GitHub Desktop.
Missile

#Missile - PushBullet made awesome

Version 1.2

Missile is a PushBullet client for Ubuntu and other Linux operating systems. It supports:

  • Send note to all devices
  • Send link to all devices
  • Send list to all devices
  • Send image to all devices
  • Send link to friend
  • Send note to friend
  • Send list to friend
  • Send image to friend

###How to set up

Download this gist by clicking on the Download Gist button, unzip package, copy missile to /usr/local/bin/ and make it executable chmod +x /usr/local/bin/missile

Then in the terminal just run missile and a popup will come up.

To make this more useful, make a file called missile.desktop in your desktop with the contents:

[Desktop Entry]
Version=1.0
Name=Missile
Exec=/usr/local/bin/missile
Icon=ICON
Terminal=false
Type=Application
Categories=Utility;Application;
Comment[en_US.UTF-8]=A Zenity GTK GUI based PushBullet client

NOTE: Replace ICON by the full path to the icon, download this icon and put it somewhere, dont delete it! then replace ICON by the full path to the icon.

##Dependencies

Missile depends on cURL. Install it using the manual

If you're on Ubuntu, zenity is installed. If you are not on Ubuntu check that you have zenity installed (run "zenity --help"). If not install zenity in your package manager.

Zenity comes pre installed in Linux, Windows

###TODO:

  • Add receive push support (background mode) with zenity alerts
  • Speech recognition?
  • Send contents of text file (using cat)
  • Add third party integration
  • Add windows
  • Add mac support
  • Go famous!
#!/bin/bash
#MISSILE 1.2
if [[ -f ~/.PBtoken ]];
then
option=`zenity --list --text "Welcome to Missile! \nSelect" --radiolist --column "" --column "" TRUE "Push note" FALSE "Push link" FALSE "Push list" FALSE "Push note to friend" FALSE "Push link to friend" FALSE "Push list to friend" FALSE "Push image" FALSE "Push image to friend" FALSE "Push text file" FALSE "Push text file to friend"`
#PUSH NOTE
if [[ $option == "Push note" ]];
then
PBtitle=`zenity --entry --text=Title --entry-text=`
PBnote=`zenity --entry --text=Content --entry-text=`;
PBtoken=`cat ~/.PBtoken`;
PBMissileID=`cat ~/.PBMissileID`;
curl -s --silent -q -u $PBtoken: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title":"'"$PBtitle"'","body":"'"$PBnote"'", "source_device_iden":"'"$PBMissileID"'"}';
zenity --info --text="Push sent"
fi
#PUSH LINK
if [[ $option == "Push link" ]];
then
PBtitle=`zenity --entry --text=Title --entry-text=`
PBnote=`zenity --entry --text="Optional Note" --entry-text=`;
PBlink=`zenity --entry --text="Link URL" --entry-text="http://"`;
PBtoken=`cat ~/.PBtoken`;
PBMissileID=`cat ~/.PBMissileID`;
curl -s --silent -q -u $PBtoken: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "link", "title":"'"$PBtitle"'","body":"'"$PBnote"'","url":"'"$PBlink"'", "source_device_iden":"'"$PBMissileID"'"}';
zenity --info --text="Push sent"
fi
#PUSH LIST
if [[ $option == "Push list" ]];
then
PBtoken=`cat ~/.PBtoken`;
PBMissileID=`cat ~/.PBMissileID`;
PBtitle=`zenity --entry --text="Title of list, NOTE: 5 bullet points only!" --entry-text=`;
PBitem1=`zenity --entry --text="Item 1" --entry-text=`;
PBitem2=`zenity --entry --text="Item 2" --entry-text=`;
PBitem3=`zenity --entry --text="Item 3" --entry-text=`;
PBitem4=`zenity --entry --text="Item 4" --entry-text=`;
PBitem5=`zenity --entry --text="Item 5" --entry-text=`;
PBlist=`echo '["'"$PBitem1"'","'"$PBitem2"'","'"$PBitem3"'","'"$PBitem4"'","'"$PBitem5"'"]'`
curl -s --silent -q -u $PBtoken: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "list", "title":"'"$PBtitle"'","items":'"$PBlist"', "source_device_iden":"'"$PBMissileID"'"}';
zenity --info --text="Push sent"
fi
#PUSH NOTE TO FRIEND
if [[ $option == "Push note to friend" ]];
then
PBfriendmail=`zenity --entry --text="Friend's email" --entry-text=`;
PBtitle=`zenity --entry --text=Title --entry-text=`
PBnote=`zenity --entry --text=Content --entry-text=`;
PBtoken=`cat ~/.PBtoken`;
PBMissileID=`cat ~/.PBMissileID`;
curl -s --silent -q -u $PBtoken: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"email": "'"$PBfriendmail"'", "type": "note", "title":"'"$PBtitle"'","body":"'"$PBnote"'", "source_device_iden":"'"$PBMissileID"'"}';
zenity --info --text="Push sent"
fi
#PUSH LINK TO FRIEND
if [[ $option == "Push link to friend" ]];
then
PBfriendmail=`zenity --entry --text="Friend's email" --entry-text=`;
PBtitle=`zenity --entry --text=Title --entry-text=`
PBnote=`zenity --entry --text=Content --entry-text=`;
PBlink=`zenity --entry --text="Link URL" --entry-text="http://"`;
PBtoken=`cat ~/.PBtoken`;
PBMissileID=`cat ~/.PBMissileID`;
curl -s --silent -q -u $PBtoken: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"email": "'"$PBfriendmail"'", "type": "link", "title":"'"$PBtitle"'","body":"'"$PBnote"'","url":"'"$PBlink"'", "source_device_iden":"'"$PBMissileID"'"}';
zenity --info --text="Push sent"
fi
#PUSH LIST TO FRIEND
if [[ $option == "Push list to friend" ]];
then
PBtoken=`cat ~/.PBtoken`;
PBMissileID=`cat ~/.PBMissileID`;
PBfriendmail=`zenity --entry --text="Friend's email" --entry-text=`;
PBtitle=`zenity --entry --text="Title of list, NOTE: 5 bullet points only!" --entry-text=`;
PBitem1=`zenity --entry --text="Item 1" --entry-text=`;
PBitem2=`zenity --entry --text="Item 2" --entry-text=`;
PBitem3=`zenity --entry --text="Item 3" --entry-text=`;
PBitem4=`zenity --entry --text="Item 4" --entry-text=`;
PBitem5=`zenity --entry --text="Item 5" --entry-text=`;
PBlist=`echo '["'"$PBitem1"'","'"$PBitem2"'","'"$PBitem3"'","'"$PBitem4"'","'"$PBitem5"'"]'`
curl -s --silent -q -u $PBtoken: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"email": "'"$PBfriendmail"'", "type": "list", "title":"'"$PBtitle"'","items":'"$PBlist"', "source_device_iden":"'"$PBMissileID"'"}';
zenity --info --text="Push sent"
fi
#PUSH IMAGE
if [[ $option == "Push image" ]];
then
PBtitle=`zenity --entry --text=Title --entry-text=`
PBimagePath=`zenity --file-selection`;
PBtoken=`cat ~/.PBtoken`;
PBMissileID=`cat ~/.PBMissileID`;
ImgurKey=e1c4ac318595f41;
curl -sH "Authorization: Client-ID $ImgurKey" -F "image=@$PBimagePath" "https://api.imgur.com/3/upload" | cut -d\" -f50 | sed 's/\\//g' > PBImage.txt;
PBImgurLink=`cat PBImage.txt`
curl -s --silent -q -u $PBtoken: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "link", "title":"'"$PBtitle"'","body":"'"$PBnote"'","url":"'"$PBImgurLink"'", "source_device_iden":"'"$PBMissileID"'"}';
rm PBImage.txt
zenity --info --text="Push sent"
fi
#PUSH IMAGE TO FRIEND
if [[ $option == "Push image to friend" ]];
then
PBfriendmail=`zenity --entry --text="Friend's email" --entry-text=`;
PBtitle=`zenity --entry --text=Title --entry-text=`
PBimagePath=`zenity --file-selection`;
PBtoken=`cat ~/.PBtoken`;
PBMissileID=`cat ~/.PBMissileID`;
ImgurKey=e1c4ac318595f41;
curl -sH "Authorization: Client-ID $ImgurKey" -F "image=@$PBimagePath" "https://api.imgur.com/3/upload" | cut -d\" -f50 | sed 's/\\//g' > PBImage.txt;
PBImgurLink=`cat PBImage.txt`
curl -s --silent -q -u $PBtoken: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"email": "'"$PBfriendmail"'", "type": "link", "title":"'"$PBtitle"'","body":"'"$PBnote"'","url":"'"$PBImgurLink"'", "source_device_iden":"'"$PBMissileID"'"}';
rm PBImage.txt
zenity --info --text="Push sent"
fi
else
NewPBtoken=`zenity --entry --text="Enter the Pushbullet Access Token, get yours here: https://www.pushbullet.com/account" --entry text=`
echo $NewPBtoken > ~/.PBtoken;
PBtoken=`cat ~/.PBtoken`;
PBMissileIDBad=`curl -u $PBtoken: -X POST https://api.pushbullet.com/v2/devices -d nickname=Missile -d type=stream | sed 's/"iden":"/\n/g' | sed 's/","created/\ncreated/g' | sed -n 2p`;
echo $PBMissileIDBad > ~/.PBMissileID;
zenity --info --text="Access token set up correctly";
fi
@Farbdose
Copy link

So... what is the difference to https://github.com/Red5d/pushbullet-bash?
But I like your Todo list, especially the receive option, the Pushbullet indicator for Linux is a bit odd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment