diff options
Diffstat (limited to '.local/bin/scst')
-rwxr-xr-x | .local/bin/scst | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/.local/bin/scst b/.local/bin/scst index 6b63009..5cce936 100755 --- a/.local/bin/scst +++ b/.local/bin/scst @@ -2,26 +2,30 @@ set -e -notify() { +notify() +{ notify-send -a ${0##*/} -i "$filename" 'Screenshot copied' \ - 'Screenshot successfully copied to the clipboard' + 'Screenshot successfully copied to the clipboard.' } -if [ $# -eq 1 -a "$1" = "-f" ]; then +if [ $# -eq 1 -a "$1" = "-f" ] +then fflag=true shift fi -[ $# -ge 1 ] && { +if [ $# -ge 1 ] +then echo "Usage: ${0##*/} [-f]" >&2 exit 1 -} +fi -outdir=${XDG_PICTURES_DIR:-$HOME/Pictures}/screen -filename="$outdir/`date +%F_%T.png`" +readonly outdir=${XDG_PICTURES_DIR:-$HOME/Pictures}/screen +readonly filename="$outdir/`date +%F_%T.png`" [ -d "$outdir" ] || mkdir -p "$outdir" -if ${fflag:-false}; then +if ${fflag:-false} +then grim "$filename" else slurp 2>/dev/null | ifne grim -g - "$filename" @@ -29,12 +33,17 @@ 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 +opt="`printf 'Copy screenshot\nEdit- and copy screenshot\n' | osel`" + +case "$opt" in +'Copy screenshot') + wl-copy <"$filename" + notify + ;; +'Edit- and copy screenshot') + swappy -f "$filename" -o - \ + | pee wl-copy cat \ + | sponge "$filename" + notify + ;; +esac |