From 1facd0220e9c5fdc07e7dea2d8aa7707ce4b7887 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Einar=20J=C3=B8rgen=20Haraldseid?= Date: Tue, 7 Apr 2015 23:24:39 +0200 Subject: [PATCH] A quick and dirty tool to take and upload screenshots --- screenshot.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 screenshot.sh diff --git a/screenshot.sh b/screenshot.sh new file mode 100755 index 0000000..858797a --- /dev/null +++ b/screenshot.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# A quick and dirty script to take a screenshot, upload it via scp +# and put a link to it in the clipboard for easy pasting to i.e. IRC. +# It assumes a lot of things, e.g. that ssh to the target host has +# been set up with a working private key, and that xclip and +# gnome-screenshot is installed. +# +# If all you have is a hammer, everything looks like a nail. + +# Settings +REMOTEUSER="einar" +REMOTEHOST="wowbagger.slaskete.net" +REMOTEPATH="/var/www/eina.rjh.im/screenshots/" +LOCALPATH="${HOME}/ownCloud/Screenshots/" +URLBASE="https://eina.rjh.im/screenshots" + +function errcho() { + >&2 echo -e "$@" +} + +function take_screenshot() { + FILENAME="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1).png" + gnome-screenshot -f "${LOCALPATH}/${FILENAME}" -p "$@" + scp -q "${LOCALPATH}/${FILENAME}" "${REMOTEUSER}@${REMOTEHOST}:${REMOTEPATH}" + printf "${URLBASE}/${FILENAME}"|xclip -selection p + printf "${URLBASE}/${FILENAME}"|xclip -selection c + notify-send -i applets-screenshooter "screenshot.sh" "Screenshot published to ${URLBASE}/${FILENAME}" +} + +function show_error() { + errcho "Please use one of: -w, --window, -a, --area, -s, --selection," + errcho " -f, --full or no argument at all." + exit 1 +} + +case ${1} in + -w|--window) + take_screenshot -w -b -e shadow + ;; + -a|--area|-s|--selection) + take_screenshot -a + ;; + ""|-f|--full) + take_screenshot + ;; + *) + show_error + ;; +esac + -- 2.30.2