-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimgurdrop
More file actions
executable file
·36 lines (33 loc) · 1.03 KB
/
imgurdrop
File metadata and controls
executable file
·36 lines (33 loc) · 1.03 KB
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
#!/bin/bash
#
# imgurdrop
#
# Watches a folder (/tmp/imgur) for new files and uploads any new files
# in folder to imgur. The imgur URL will then appear in your clipboard.
#
# Intended to be used as a daemon, via dtach, screen, or simply "imgurdrop &"
#
# Originally inspired by:
# http://sirupsen.com/a-simple-imgur-bash-screenshot-utility/
#
# Dependencies:
#
# Xclip
# Comment: Xclip is what makes the script able to inject the direct url
# into your clipboard.
#
# libnotify*
# Comment: Will notify you whenever the direct URL is in the clipboard
#
# inotify-tools
# Comment: allows monitoring of the imgur drop directory
#
function uploadImage {
curl -s -F "image=@$1" -F "key=486690f872c678126a2c09a9e196ce1b" http://imgur.com/api/upload.xml | grep -E -o "<original_image>(.)*</original_image>" | grep -E -o "http://i.imgur.com/[^<]*"
}
mkdir /tmp/imgur 2>/dev/null
while true; do
file=`inotifywait -q -e create --format '%f' /tmp/imgur`
uploadImage /tmp/imgur/$file | xclip -selection c
notify-send "$file uploaded to imgur"
done