2 # A quick and dirty script to take a screenshot, upload it via scp
3 # and put a link to it in the clipboard for easy pasting to i.e. IRC.
4 # It assumes a lot of things, e.g. that ssh to the target host has
5 # been set up with a working private key, and that xclip and
6 # gnome-screenshot is installed.
8 # If all you have is a hammer, everything looks like a nail.
12 RemoteHost
="wowbagger.slaskete.net"
13 RemotePath
="/var/www/eina.rjh.im/screenshots/"
14 LocalPath
="${HOME}/Pictures/Screenshots/"
15 UrlBase
="https://eina.rjh.im/g"
21 function take_screenshot
() {
22 FileID
="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 6 | head -n 1)"
23 FileName
="${FileID}.png"
24 if [ "$*" = "clipboard" ] ||
[ "$*" = "jpg" ]; then
25 xclip
-out -selection clipboard
-t image
/png
> "/tmp/${FileName}" 2>/dev
/null
26 if [ "$(file -b --mime-type "/tmp
/${FileName}")" == "image/png" ]; then
27 if [ "$*" = "jpg" ]; then
28 convert
"/tmp/${FileName}" "/tmp/${FileID}.jpg"
30 FileName
="${FileID}.jpg"
32 mv "/tmp/${FileName}" "${LocalPath}/"
35 notify-send
-i applets-screenshooter
"screenshot.sh" "Tried to post image from clipboard, but found no image there."
38 gnome-screenshot
-f "${LocalPath}/${FileName}" -p "$@"
40 if [ -f "${LocalPath}/${FileName}" ]; then
41 scp
-q "${LocalPath}/${FileName}" "${RemoteUser}@${RemoteHost}:${RemotePath}"
42 echo -n "${UrlBase}/${FileName}"|xclip
-selection p
43 echo -n "${UrlBase}/${FileName}"|xclip
-selection c
44 notify-send
-i applets-screenshooter
"screenshot.sh" "Screenshot published to ${UrlBase}/${FileName}"
48 function show_error
() {
49 errcho
"Please use one of: -w, --window, -a, --area, -s, --selection,"
50 errcho
" -f, --full or no argument at all."
56 take_screenshot
-w -b -e shadow
58 -a|
--area|
-s|
--selection)
65 -c|
--clipboard|
-p|
--paste)
66 take_screenshot clipboard