|
#!/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 |
https://gist.github.com/CraftThatBlock/f815626a5bd70d1aa8f1/d852f3198a34a8cc4d951090befb0aad064ea246
Fixed your bash to make it easier to read :)