- FileName="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 6 | head -n 1).png"
- if [ "$@" = "clipboard" ]; then
- xclip -out -selection clipboard -t image/png > "${LocalPath}/${FileName}" 2>/dev/null
+ FileID="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 6 | head -n 1)"
+ FileName="${FileID}.png"
+ if [ "$*" = "clipboard" ] || [ "$*" = "jpg" ]; then
+ xclip -out -selection clipboard -t image/png > "/tmp/${FileName}" 2>/dev/null
+ if [ "$(file -b --mime-type "/tmp/${FileName}")" == "image/png" ]; then
+ if [ "$*" = "jpg" ]; then
+ convert "/tmp/${FileName}" "/tmp/${FileID}.jpg"
+ rm "/tmp/${FileName}"
+ FileName="${FileID}.jpg"
+ fi
+ mv "/tmp/${FileName}" "${LocalPath}/"
+ else
+ rm "/tmp/${FileName}"
+ notify-send -i applets-screenshooter "screenshot.sh" "Tried to post image from clipboard, but found no image there."
+ fi