diff options
| author | Warrick Lo <warrick.s.z.lo@gmail.com> | 2021-12-19 00:38:25 -0800 |
|---|---|---|
| committer | Warrick Lo <warrick.s.z.lo@gmail.com> | 2021-12-19 00:38:25 -0800 |
| commit | a8b7e9bb50cb8f2e5a3d8ad34eb266dda7b518d7 (patch) | |
| tree | 6a3aca32e93bf1ff74db24155f3a6966c68a643e /bin/screenshot | |
| parent | 487d64163c59fa3de79b5ff1abf303475395c4a2 (diff) | |
Add screenshot script
Diffstat (limited to 'bin/screenshot')
| -rwxr-xr-x | bin/screenshot | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/bin/screenshot b/bin/screenshot new file mode 100755 index 0000000..1cf96fd --- /dev/null +++ b/bin/screenshot @@ -0,0 +1,31 @@ +#!/bin/sh + +# Capture screen with maim. +# +# Either screenshot entire screen or manually select a region. Saves to a +# screenshots directory and optionally copies to clipboard. + +command -v maim > /dev/null || exit 1 + +dir="$(xdg-user-dir PICTURES)/screenshots" +path="$dir/$(date '+%Y-%m-%dT%H:%M:%S').png" + +if [ ! -d "$dir" ]; then + mkdir "$dir" +fi + +if [ "$1" = "region" ]; then + args="-s -b 1 -c 0.92,0.86,0.70" +elif [ "$1" = "full" ]; then + args="" +else + echo "Usage: screenshot [region|full] <clipboard>" + exit 1 +fi + +# shellcheck disable=SC2086 +if [ "$2" = "clipboard" ]; then + maim $args | tee "$path" | xclip -selection clipboard -t image/png +else + maim $args "$path" +fi |
