forked from Nokorot/dotbin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprtscreen
executable file
·56 lines (44 loc) · 1.29 KB
/
prtscreen
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
52
53
54
55
#!/bin/bash
source ~/.uservars
options="-quality 98"
preview="feh"
[ -z $PICTURES ] && PICTURES="$HOME/Pictures/"
savepath="$PICTURES/"
mkdir -p $savepath
tmpimg=$(mktemp -u).png
savefile() {
echo "$savepath"pic-"$(date '+%y%m%d-%H%M-%S').png"
}
echo $1
case $1 in
# TODO: area)
win) import $options "$tmpimg" ;;
curwin) import -window "$(get_winId)" "$tmpimg" ;;
""|root) import -window root $options "$tmpimg" ;;
esac
while true; do
res="$(printf "quit\nsave\nsave as\npreview\ndragon" | dmenu -p "ScreenShot: ")"
case "$res" in
quit | "") break ;;
save)
cp "$tmpimg" "$(savefile)" ;
notify-send "Screenshot saved to $(savefile)";;
"save as")
fp="$(printf "$savepath\n$(savefile)" | dmenu)" || continue;
cp "$tmpimg" "$fp";
notify-send "Screenshot saved to $(fp)";;
dragon) dragon-drop --and-exit "$tmpimg" ;;
preview)
[ -z "$child" ] && {
i3-on_open --name 'feh' \
"floating enable;" \
"resize set 1400px 800px;" \
"move position center;" &
feh -. "$tmpimg" &
child="${!}";
} ;;
# copy)
esac
done
# kill "$child"
rm "$tmpimg"