-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenshot_actions.sh
executable file
·96 lines (86 loc) · 2.43 KB
/
screenshot_actions.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
# www.jrodal.dev
source $HOME/.config/dunst/variables.sh
function rename() {
FILENAME=$(zenity --file-selection --file-filter=*.png --confirm-overwrite --title="Save screenshot as..." --save --filename="$1")
case $? in
0 )
mv $1 $FILENAME
;;
esac
}
function saveas() {
FILENAME=$(zenity --file-selection --file-filter=*.png --confirm-overwrite --title="Save screenshot as..." --save --filename="$SCREENSHOT_DIR/$(date +%s).png")
case $? in
0 )
xclip -o -selection clipboard -t image/png > $FILENAME
;;
esac
}
function delete() {
case $(echo -e "yes\nno" | dmenu -p "Are you sure you want to delete the screenshot?") in
yes )
rm $1
dunstify -i $CAMERA_ICON "Screenshot has been deleted"
;;
esac
}
function ocr() {
xclip -o -selection clipboard -t image/png | tesseract -l $OCR_LANG stdin stdout | xclip -sel clip
dunstify -i $OCR_ICON "Text copied to clipboard"
}
function to_clip() {
xclip -sel clip -t image/png $1
case $2 in
moved )
rm $1
;;
*)
;;
esac
dunstify -i $CAMERA_ICON "Image $2 to clipboard"
}
function upload_0x0() {
case $1 in
clipboard )
FILENAME=/tmp/screenshot-actions.png
xclip -o -selection clipboard -t image/png > $FILENAME
;;
*)
FILENAME=$1
;;
esac
URL=$(curl -F"file=@$FILENAME" http://0x0.st)
dunstify -i $CAMERA_ICON "Image uploaded to $URL"
}
case $1 in
clipboard)
ACTION=$(play_sound & dunstify -A "saveas,save as" -A "ocr,ocr" -A "upTo0x0,upload to 0x0.st" -i $HOME/.local/share/icons/dunst_icons/icons8-camera-100.png "Screenshot" "Screenshot saved to clipboard")
;;
*)
ACTION=$(play_sound & dunstify -A "rename,rename" -A "delete,delete" -A "mvToClip,move to clipboard" -A "cpToClip,copy to clipboard" -A "upTo0x0,upload to 0x0.st" -i $HOME/.local/share/icons/dunst_icons/icons8-camera-100.png "Screenshot" "Screenshot saved to $1")
;;
esac
case "$ACTION" in
"rename")
rename $1
;;
"saveas")
saveas
;;
"delete")
delete $1
;;
"ocr")
ocr
;;
"cpToClip")
to_clip $1 copied
;;
"mvToClip")
to_clip $1 moved
;;
"upTo0x0")
upload_0x0 $1
;;
esac