#!/usr/local/bin/andy set -e NOTIFY_LONG screenshot set -e NOTIFY_SHORT `basename $args[0] func xnotify { notify ( 'Screenshot Saved' "The screenshot ‘$filebase’ was successfully saved" -i $filename ) } if test $#args -eq 2 && test $args[1] = '-f' { set fflag true set args $args[1..] } if test $#args -gt 1 { echo "Usage: `{basename $args[0]} [-f]" >/dev/stderr exit 1 } set outdir $(XDG_PICTURES_DIR:$HOME/Pictures)/screen set filebase `date +%F_%T.png set filename $outdir/$filebase [ -d $outdir ] || mkdir -p $outdir if $(fflag:false) { grim $filename } else { # TODO: Redirect slurp stderr to /dev/null slurp | ifne grim -g - $filename } [ -f $filename ] || exit 1 set opt `echo "Copy screenshot\nEdit- and copy screenshot" | { osel || true } if test $opt = 'Copy screenshot' { wl-copy <$filename notify ( 'Screenshot Copied' 'Screenshot successfully copied to the clipboard' -i $filename ) } else if test $opt = 'Edit- and copy screenshot' { satty -f $filename --save-after-copy xnotify # swappy -f $filename -o - | tee >{wl-copy} | sponge $filename } else { xnotify }