aboutsummaryrefslogtreecommitdiff
path: root/bin/shot
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-02-15 16:24:52 -0300
committerEuAndreh <eu@euandre.org>2023-02-15 16:24:52 -0300
commit5d04fb026a9d1c42f74767aba2f81e8c7dbbe44a (patch)
tree19a461826320d5eb99053d7fe6f2f140c9e9f68f /bin/shot
parentetc/git/config: Enable rerere (diff)
downloaddotfiles-5d04fb026a9d1c42f74767aba2f81e8c7dbbe44a.tar.gz
dotfiles-5d04fb026a9d1c42f74767aba2f81e8c7dbbe44a.tar.xz
bin/shot: Add working helper utility
Diffstat (limited to 'bin/shot')
-rwxr-xr-xbin/shot78
1 files changed, 78 insertions, 0 deletions
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/"