Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 98 lines (81 sloc) 2.42 KB
#!/usr/bin/env bash
# poomf.sh
# Author: Joe Schillinger, William Woodruff
# ------------------------
# Upload to an RSUS endpoint (currently thing-in-itself).
# Heavily modified from Joe Schillinger's poomf.sh (now uguu.sh).
# ------------------------
# This code is licensed by Joe Schillinger under the MIT License.
# http://opensource.org/licenses/MIT
function usage() {
echo "$(basename "${0}") <option>"
echo "Options:"
echo -e "\t-e\tdon't strip exif data"
echo -e "\t-i\tinteractive (zenity)"
echo -e "\t-f\tfullscreen screenshot"
echo -e "\t-h\tshow this message"
echo -e "\t-s\tselection screenshot"
echo -e "\t-u\t<file>" "file upload"
exit
}
function info() {
notify-send "poomf" "${*}"
}
function installed() {
cmd=$(command -v "${1}")
[[ -n "${cmd}" ]] && [[ -f "${cmd}" ]]
return ${?}
}
function check_dependencies() {
local deps=(notify-send zenity xclip curl jq exiftool maim kbsecret)
for dep in "${deps[@]}"; do
if ! installed "${dep}" ; then
echo "Missing dependency '${dep}', please install it."
exit 1
fi
done
}
check_dependencies
# get options
while getopts eifhsu: option; do
case "${option}" in
e) keepexif=1 ;;
i) interactive=1 ;;
f) fullscreen=1 ;;
h) usage ;;
s) selection=1 ;;
u) file="${OPTARG}" ;;
*) exit ;;
esac
done
if [[ "${interactive}" ]]; then
file=$(zenity --file-selection)
elif [[ ! "${file}" ]]; then
file=~/Dropbox/screenshots/$(date +%s).png
if [[ "${fullscreen}" ]]; then
maim "${file}"
elif [[ "${selection}" ]]; then
maim --bordersize 4000 --color=0.2,0.2,0.2,0.9 -s "${file}"
fi
fi
if [[ ! -f "${file}" ]]; then
info "file was not uploaded (no file specified)"
exit 2
fi
if [[ ! "${keepexif}" ]]; then
exiftool -overwrite_original -all= "${file}" > /dev/null
fi
eval "$(kbsecret env -s keys rsus-api-key)"
if [[ -n "${RSUS_API_KEY}" ]]; then
output=$(curl -sf -F auth="${RSUS_API_KEY}" -F file="@${file}" "https://thing-in-itself.net/upload/")
if [[ -n "${output}" ]]; then
url=$(echo "${output}" | jq -M -r ".url")
echo "${url}" | xclip -selection primary
echo "${url}" | xclip -selection clipboard
info "${url}"
else
info "file was not uploaded (invalid file or server error?)"
fi
else
info "missing API key?"
fi
You can’t perform that action at this time.