diff --git a/README.md b/README.md index dc849cb..ca44041 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 @@ -17,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 new file mode 100755 index 0000000..2e08a80 --- /dev/null +++ b/install.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +mkdir -p /usr/local/bin +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/icon.png b/puush.png similarity index 100% rename from icon.png rename to puush.png diff --git a/puush b/puush.sh similarity index 73% rename from puush rename to puush.sh index dedd3a0..be60a13 100755 --- a/puush +++ b/puush.sh @@ -1,5 +1,6 @@ #!/bin/bash -# Set API Key here + +PUUSH_CONFIG_FILE="$HOME/.puush" PUUSH_API_KEY="" # Puush for Ubuntu/linux @@ -17,7 +18,8 @@ PUUSH_API_KEY="" # 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) # @@ -33,6 +35,14 @@ PUUSH_API_KEY="" # - 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 () { @@ -49,7 +59,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 } @@ -75,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 $0" - echo "You can find your API key at http://puush.me/account/settings" + 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 )/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 $PUUSH_CONFIG_FILE" "You can find your API key at http://puush.me/account/settings" exit 1