From 3dd1719fde19a3873b67455ad64ecf6f394714e0 Mon Sep 17 00:00:00 2001 From: Travis Willard Date: Tue, 27 Oct 2015 10:46:32 -0400 Subject: [PATCH 1/3] Make PUUSH_API_KEY multi-account configurable, rename icon.png to puush.png so it's more specific when installed in the system, and add a simple install script to put the stuff in /usr/local/bin --- install.sh | 6 ++++++ puush | 13 ++++++++----- icon.png => puush.png | Bin 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100755 install.sh rename icon.png => puush.png (100%) diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..7b9e4f7 --- /dev/null +++ b/install.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +mkdir -p /usr/local/bin +cp ./puush ./puush.png /usr/local/bin +chmod 755 /usr/local/bin/puush +chmod 644 /usr/local/bin/puush.png diff --git a/puush b/puush index dedd3a0..227f69e 100755 --- a/puush +++ b/puush @@ -1,6 +1,9 @@ #!/bin/bash -# Set API Key here + PUUSH_API_KEY="" +if [ -f $HOME/.puush ]; then + source $HOME/.puush +fi # Puush for Ubuntu/linux # Owner : Sunmock Yang @@ -49,7 +52,7 @@ function puushFile () if [ ! -z "$fileURL" ]; then #Copy link to clipboard, show notification printf $fileURL | xclip -selection "clipboard" - notify-send -i "$( cd "$( dirname "$0" )" && pwd )/icon.png" -t 2000 "puush complete!" "$fileURL" + notify-send -i "$( cd "$( dirname "$0" )" && pwd )/puush.png" -t 2000 "puush complete!" "$fileURL" fi } @@ -77,10 +80,10 @@ function generateFileName () { echo "/tmp/puush-linux ($(date +"%Y-%m-%d at %I.% if [ -z "$PUUSH_API_KEY" ]; then - echo "Set the variable PUUSH_API_KEY in $0" - echo "You can find your API key at http://puush.me/account/settings" + echo "Set the variable PUUSH_API_KEY in \$HOME/.puush" >/dev/stderr + echo "You can find your API key at http://puush.me/account/settings" >/dev/stderr - notify-send -i "$( cd "$( dirname "$0" )" && pwd )/icon.png" "Set the variable PUUSH_API_KEY in $0" "You can find your API key at http://puush.me/account/settings" + notify-send -i "$( cd "$( dirname "$0" )" && pwd )/puush.png" "Set the variable PUUSH_API_KEY in \$HOME/.puush" "You can find your API key at http://puush.me/account/settings" exit 1 diff --git a/icon.png b/puush.png similarity index 100% rename from icon.png rename to puush.png From d9c40ba2bb365bf3ecb975674d14814af2ef6952 Mon Sep 17 00:00:00 2001 From: Travis Willard Date: Tue, 27 Oct 2015 11:04:47 -0400 Subject: [PATCH 2/3] Some further cleanup, updating README.md for the new config file, and helpfully autogenerate a default config file if it doesn't exist --- README.md | 8 +++++--- puush | 25 +++++++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index dc849cb..fd159a2 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,12 @@ Takes screenshots and uploads them to puush using the puush API and copies the l ## Instructions - Clone or download the repo -- In file "puush" add your puush API key to PUUSH_API_KEY +- Run "install.sh" to install to /usr/local/bin + - Alternatively you can install wherever you want +- On first run of 'puush' a default config file will be generated into + $HOME/.puush +- In this config file add your puush API key to PUUSH_API_KEY - (You can find your API key at http://puush.me/account/settings) -- Make it executable using __chmod +x puush__ -- Place this file wherever you want (recommended: /usr/local/bin) - Set up keyboard shortcuts within linux - (in Ubuntu it's system settings > keyboard > keyboard shortcuts > custom shortcuts) - Log out for the changes to take place diff --git a/puush b/puush index 227f69e..be60a13 100755 --- a/puush +++ b/puush @@ -1,9 +1,7 @@ #!/bin/bash +PUUSH_CONFIG_FILE="$HOME/.puush" PUUSH_API_KEY="" -if [ -f $HOME/.puush ]; then - source $HOME/.puush -fi # Puush for Ubuntu/linux # Owner : Sunmock Yang @@ -20,7 +18,8 @@ fi # Licence : Beerware # # Instructions: -# - Add your puush API key to PUUSH_API_KEY (You can find your API key at http://puush.me/account/settings) +# - Configure your puush API key by adding PUUSH_API_KEY to the $HOME/.puush file +# - You can find your API key at http://puush.me/account/settings # - Place this file wherever you want (/usr/local/bin) # - Set up keyboard shortcuts within linux (in Ubuntu it's system settings > keyboard > keyboard shortcuts > custom shortcuts) # @@ -36,6 +35,14 @@ fi # - Link(s) will be copied into clipboard and appear in notifications # - puush curl upload code borrowed from online sources +function createDefaultConfigFile() +{ + echo "# Configure your puush API key here" >> $PUUSH_CONFIG_FILE + echo "# - You can find your API key at http://puush.me/account/settings" >> $PUUSH_CONFIG_FILE + echo "PUUSH_API_KEY=\"\"" >> $PUUSH_CONFIG_FILE + echo >> $PUUSH_CONFIG_FILE +} + # Usage: puushFile [fileName] function puushFile () { @@ -78,12 +85,18 @@ function helpText () function generateFileName () { echo "/tmp/puush-linux ($(date +"%Y-%m-%d at %I.%M.%S")).png"; } +if [ -f $PUUSH_CONFIG_FILE ]; then + source $PUUSH_CONFIG_FILE +else + echo "Creating default config file in $PUUSH_CONFIG_FILE" + createDefaultConfigFile +fi if [ -z "$PUUSH_API_KEY" ]; then - echo "Set the variable PUUSH_API_KEY in \$HOME/.puush" >/dev/stderr + echo "Set the variable PUUSH_API_KEY in $PUUSH_CONFIG_FILE" >/dev/stderr echo "You can find your API key at http://puush.me/account/settings" >/dev/stderr - notify-send -i "$( cd "$( dirname "$0" )" && pwd )/puush.png" "Set the variable PUUSH_API_KEY in \$HOME/.puush" "You can find your API key at http://puush.me/account/settings" + notify-send -i "$( cd "$( dirname "$0" )" && pwd )/puush.png" "Set the variable PUUSH_API_KEY in $PUUSH_CONFIG_FILE" "You can find your API key at http://puush.me/account/settings" exit 1 From 42dae0d2ef1f8daeb44a8e8cbf0f062111e69d70 Mon Sep 17 00:00:00 2001 From: Travis Willard Date: Wed, 28 Oct 2015 16:42:05 -0400 Subject: [PATCH 3/3] Rename puush to puush.sh --- README.md | 10 +++++----- install.sh | 4 ++-- puush => puush.sh | 0 3 files changed, 7 insertions(+), 7 deletions(-) rename puush => puush.sh (100%) diff --git a/README.md b/README.md index fd159a2..ca44041 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,12 @@ Takes screenshots and uploads them to puush using the puush API and copies the l ### Commands ``` bash -puush -a # puush desktop -puush -b # area puush -puush -c # puush window -puush -d # file upload +puush.sh -a # puush desktop +puush.sh -b # area puush +puush.sh -c # puush window +puush.sh -d # file upload -puush -h # help +puush.sh -h # help ``` ## Dependencies diff --git a/install.sh b/install.sh index 7b9e4f7..2e08a80 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/bash mkdir -p /usr/local/bin -cp ./puush ./puush.png /usr/local/bin -chmod 755 /usr/local/bin/puush +cp ./puush.sh ./puush.png /usr/local/bin +chmod 755 /usr/local/bin/puush.sh chmod 644 /usr/local/bin/puush.png diff --git a/puush b/puush.sh similarity index 100% rename from puush rename to puush.sh