diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-08-22 16:08:42 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-08-22 16:08:42 +0200 |
commit | b71e4385f5728ac33e48224c42f54135850217c1 (patch) | |
tree | 2533bc2cc1aaa270e303b8fc0a40080232e1c418 /.local/bin/scst | |
parent | 9da60f9ab686cd05ed173f4e8f81738cc76a8585 (diff) |
scst: Add a screenshotting utility
Diffstat (limited to '.local/bin/scst')
-rwxr-xr-x | .local/bin/scst | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/.local/bin/scst b/.local/bin/scst new file mode 100755 index 0000000..6b63009 --- /dev/null +++ b/.local/bin/scst @@ -0,0 +1,40 @@ +#!/bin/sh + +set -e + +notify() { + notify-send -a ${0##*/} -i "$filename" 'Screenshot copied' \ + 'Screenshot successfully copied to the clipboard' +} + +if [ $# -eq 1 -a "$1" = "-f" ]; then + fflag=true + shift +fi + +[ $# -ge 1 ] && { + echo "Usage: ${0##*/} [-f]" >&2 + exit 1 +} + +outdir=${XDG_PICTURES_DIR:-$HOME/Pictures}/screen +filename="$outdir/`date +%F_%T.png`" +[ -d "$outdir" ] || mkdir -p "$outdir" + +if ${fflag:-false}; then + grim "$filename" +else + slurp 2>/dev/null | ifne grim -g - "$filename" +fi + +[ -f "$filename" ] || exit 1 + +printf 'Copy screenshot\nEdit- and copy screenshot\n' \ + | osel \ + | if read res && [ "$res" = 'Copy screenshot' ]; then + wl-copy <"$filename" + notify + elif [ "$res" = 'Edit- and copy screenshot' ]; then + swappy -f "$filename" -o - | pee wl-copy cat | sponge "$filename" + notify + fi |