X-Git-Url: https://git.slaskete.net/einar-bin/blobdiff_plain/62175bff02c30430bae5ce9690d987cd2dc2277c..e3f52b30f6c8b191aa48647a5ee1e46f52e6d386:/screenshot.sh?ds=sidebyside diff --git a/screenshot.sh b/screenshot.sh index 56ccf5b..2649ddf 100755 --- a/screenshot.sh +++ b/screenshot.sh @@ -11,7 +11,7 @@ RemoteUser="einar" RemoteHost="wowbagger.slaskete.net" RemotePath="/var/www/eina.rjh.im/screenshots/" -LocalPath="${HOME}/ownCloud/Screenshots/" +LocalPath="${HOME}/Pictures/Screenshots/" UrlBase="https://eina.rjh.im/g" function errcho() { @@ -19,9 +19,21 @@ function errcho() { } function take_screenshot() { - 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 else gnome-screenshot -f "${LocalPath}/${FileName}" -p "$@" fi @@ -35,7 +47,7 @@ function take_screenshot() { function show_error() { errcho "Please use one of: -w, --window, -a, --area, -s, --selection," - errcho " -f, --full or no argument at all." + errcho " -f, --full, -j, --jpg or no argument at all." exit 1 } @@ -53,6 +65,9 @@ case ${1} in -c|--clipboard|-p|--paste) take_screenshot clipboard ;; + -j|--jpg) + take_screenshot jpg + ;; *) show_error ;;