blob: 46bdcbef75c217f0867541f74469e53594bf0860 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/usr/local/bin/andy
set -e NOTIFY_LONG screenshot
set -e NOTIFY_SHORT `basename $args[0]
func xnotify {
notify (
'Screenshot Copied'
'Screenshot successfully copied to the clipboard'
-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
xnotify
} else if test $opt = 'Edit- and copy screenshot' {
swappy -f $filename -o - | tee >{wl-copy} | sponge $filename
xnotify
} else {
notify (
'Screenshot Saved'
"The screenshot ‘$filebase’ was successfully saved"
-i $filename
)
}
|