From 5d04fb026a9d1c42f74767aba2f81e8c7dbbe44a Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 15 Feb 2023 16:24:52 -0300 Subject: bin/shot: Add working helper utility --- bin/shot | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 bin/shot (limited to 'bin') diff --git a/bin/shot b/bin/shot new file mode 100755 index 0000000..91f3310 --- /dev/null +++ b/bin/shot @@ -0,0 +1,78 @@ +#!/bin/sh +set -eu + +usage() { + cat <<-'EOF' + Usage: + shot [-m] + shot -h + EOF +} + +help() { + cat <<-'EOF' + + + Options: + -m use the mouse to select the region to screen shot + -h, --help show this message + + + Take a screenshot. The default is to print the whole screen, but + the "-m" can be given to select only a part of the screen. + + The screenshots are saved to ~/Downloads/Screenshots/ + + + Examples: + + Take screenshot of the full screen: + + $ shot + + + Select the region of the screenshot: + + $ shot -m + EOF +} + + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +OPTS= +while getopts 'mh' flag; do + case "$flag" in + m) + OPTS='-s' + ;; + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + +TEMPLATE=~/Downloads/Screenshots/%Y-%m-%dT%H:%M:%S.png + +scrot $OPTS "$TEMPLATE" +msg -D "screenshot saved on ~/Downloads/Screenshots/" -- cgit v1.2.3