Created
April 9, 2015 20:41
-
-
Save akovalyov/aa8dc571e2034ad30472 to your computer and use it in GitHub Desktop.
Take screenshot, upload it to your owncloud instance immediately, set share time to 24 hours and push the link of the shared screenshot to the clipboard. It assumes that you move the original gnome-screenshot tool from /usr/bin/gnome-screenshot to /usr/bin/gnome-screenshot.bin and put this shell script to /usr/bin/gnome-screeshot. Sorry, there i…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USER="!!!USER!!!" #changeme | |
PASSWORD="!!!PASSWORD!!!" #changeme | |
URL="!!!DOMAIN!!!" #changeme | |
SCHEME="!!!https or http!!!" #changeme | |
SCREENS_DIR=Screenshots #changeme or not | |
YEAR=$(date +"%Y") | |
NOW=$(date +"%m_%d_%s") | |
FULL_URL="$SCHEME://$USER:$PASSWORD@$URL" | |
RELATIVE_PATH=$SCREENS_DIR/$YEAR/Screenshot-$NOW.png | |
gnome-screenshot.bin -f /tmp/Screenshot-$NOW.png | |
#creating folders | |
curl -k -X MKCOL "$FULL_URL/remote.php/webdav/$SCREENS_DIR" | |
curl -k -X MKCOL "$FULL_URL/remote.php/webdav/$SCREENS_DIR/$YEAR" | |
#uploading file itself | |
curl -k -X PUT "$FULL_URL/remote.php/webdav/$RELATIVE_PATH" -T "/tmp/Screenshot-$NOW.png" | |
#creating share | |
response=$(curl $FULL_URL/ocs/v1.php/apps/files_sharing/api/v1/shares -k -X POST --data "path=$RELATIVE_PATH&shareType=3") | |
shareId=$(grep -oPm1 "(?<=<id>)[^<]+" <<< "$response") | |
resourceUrl=$(grep -oPm1 "(?<=<url>)[^<]+" <<< "$response") | |
#set share lifetime to one day | |
tomorrow=$(date --date="1 day" +"%Y-%m-%d %H:%d:%S") | |
curl -k -X POST $FULL_URL/ocs/v1.php/apps/files_sharing/api/v1/shares/$shareId --data "expireDate=$tomorrow" | |
#removing & | |
echo $resourceUrl | sed 's/amp;//g' | xclip -selection clipboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment