From 6aa63624e9f9295b64c9bcd1b570fbcfff569f71 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Einar=20J=C3=B8rgen=20Haraldseid?= Date: Sat, 27 May 2017 12:32:31 +0200 Subject: [PATCH] Improved clipboard function --- screenshot.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/screenshot.sh b/screenshot.sh index 56ccf5b..ec1931b 100755 --- a/screenshot.sh +++ b/screenshot.sh @@ -21,7 +21,13 @@ 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 + xclip -out -selection clipboard -t image/png > "/tmp/${FileName}" 2>/dev/null + if [ "$(file -b --mime-type /tmp/${FileName})" == "image/png" ]; then + 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 -- 2.30.2