#!/usr/bin/env bash

LATEST_SCROT="$HOME/pics/scrots/latest.png"

upload() {
    out="$(curl -s -F "file=@$1" -F "key=$(pw -s fsrv)" https://x.icyphox.sh)"
    [[ ! "$NO_CP" -eq 1 ]] && {
        case "$OSTYPE" in
            darwin*)
                printf "$out" | pbcopy
                ;;
            *)
                printf "$out" | xclip -sel c
                ;;
        esac
    }
    printf "$out\n"
}

if [ "$1" == "l" ]; then
    upload "$LATEST_SCROT"
elif [ "$1" != "l" ]; then
   upload "$1"
fi