Skip to content

Instantly share code, notes, and snippets.

@slice
Last active July 30, 2017 22:57
Show Gist options
  • Save slice/1567f791b01e96f4e1e2abc27e48b1fe to your computer and use it in GitHub Desktop.
Save slice/1567f791b01e96f4e1e2abc27e48b1fe to your computer and use it in GitHub Desktop.
owo client for macos
#!/bin/bash
# -----------------------------------
# - qwq, light owo client for macos -
# -----------------------------------
#
# (c) slice 2017
# dependencies:
# - jq (brew install jq)
# - osacsript (macos only, preinstalled)
# - curl (preinstalled in macos)
# - pbcopy (macos only, preinstalled)
# --- configurables
# directory in which to store screenshots
SCREENSHOT_DIRECTORY="$HOME/Pictures/screenshots"
# date format
DATE_FORMAT="%m-%d-%Y-%I:%M:%S-%p"
# your owo token
TOKEN="XXXX-XXXX-XXXX-XXXX-XXXX"
# path to save
SAVE_PATH="$SCREENSHOT_DIRECTORY/$(date +$DATE_FORMAT).png"
# vanity url
VANITY="owo.sh"
# ---
mkdir -p "$SCREENSHOT_DIRECTORY"
# screencap
screencapture -di "$SAVE_PATH"
if [[ "$?" == "1" ]]; then
echo "Screencapture cancelled."
exit 1
fi
echo "Saved to: $SAVE_PATH"
# upload
echo "Uploading..."
OWO_OUTPUT=$(curl -s -F "files[]=@\"$SAVE_PATH\";type=image/png" https://api.awau.moe/upload/pomf?key="$TOKEN" \
-H "User-Agent: qwq.sh (https://github.com/slice)")
echo "Uploaded!"
# upload to owo
FILE=$(echo "$OWO_OUTPUT" | jq -r ".files[0].url")
URL="https://$VANITY/$FILE"
# copy
echo -n "$URL" | pbcopy
echo "Copied to clipboard: $URL"
# notify
/usr/bin/osascript -e "display notification \"$URL\" with title \"Uploaded!\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment