X-Git-Url: https://git.slaskete.net/einar-bin/blobdiff_plain/e3f52b30f6c8b191aa48647a5ee1e46f52e6d386..f864072b93bf89fc47ef6e4fa265cd3f34a2d94c:/screenshot.sh?ds=sidebyside diff --git a/screenshot.sh b/screenshot.sh index 2649ddf..bf0999c 100755 --- a/screenshot.sh +++ b/screenshot.sh @@ -2,11 +2,15 @@ # 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 +# been set up with a working logon with private key, and that xclip and # gnome-screenshot is installed. # # If all you have is a hammer, everything looks like a nail. +# TODO: +# * Undo function +# * Check that we don't overwrite an existing file (theoretically possible, but unlikely) + # Settings RemoteUser="einar" RemoteHost="wowbagger.slaskete.net" @@ -32,7 +36,7 @@ function take_screenshot() { 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." + notify-send -a "screenshot.sh" -i dialog-warning "Ooopsie" "Tried to post image from clipboard, but found no image there." fi else gnome-screenshot -f "${LocalPath}/${FileName}" -p "$@" @@ -41,19 +45,29 @@ function take_screenshot() { scp -q "${LocalPath}/${FileName}" "${RemoteUser}@${RemoteHost}:${RemotePath}" echo -n "${UrlBase}/${FileName}"|xclip -selection p echo -n "${UrlBase}/${FileName}"|xclip -selection c - notify-send -i applets-screenshooter "screenshot.sh" "Screenshot published to ${UrlBase}/${FileName}" + notify-send -a "screenshot.sh" -i applets-screenshooter "Screenshot uploaded" "Screenshot published to ${UrlBase}/${FileName}" fi } -function show_error() { - errcho "Please use one of: -w, --window, -a, --area, -s, --selection," - errcho " -f, --full, -j, --jpg or no argument at all." +function show_help() { + errcho "Usage: screenshot.sh [option]" + errcho "This script wraps gnome-screenshot in order to instantly upload screenshots and get back a URL for sharing to IRC or other social media" + errcho "The default option is to take a screenshot of the whole screen." + errcho "The following options are available:" + errcho "-f, --full Take screenshot of the whole screen" + errcho "-w, --window Take screenshot of the active window" + errcho "-a, --area Take screenshot of an area/selection" + errcho "-s, --selection Take screenshot of an area/selection" + errcho "-c, --clipboard Upload image from paste buffer if present" + errcho "-p, --paste Upload image from paste buffer if present" + errcho "-j, --jpg, --jpeg Convert image from paste buffer to jpeg and upload" + errcho "-h, --help Show this help" exit 1 } case ${1} in -w|--window) - take_screenshot -w -b -e shadow + take_screenshot -w -b ;; -a|--area|-s|--selection) sleep 0.2 @@ -65,11 +79,15 @@ case ${1} in -c|--clipboard|-p|--paste) take_screenshot clipboard ;; - -j|--jpg) + -j|--jpg|--jpeg) take_screenshot jpg ;; + -h|--help) + show_help + ;; *) - show_error + errcho "ERROR: Unknown option." + show_help ;; esac