forked from slice/qwq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qwq.sh
executable file
·71 lines (55 loc) · 1.67 KB
/
qwq.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
#!/bin/bash
# -----------------------------------
# - qwq, light owo client for macos -
# -----------------------------------
# (c) slice 2017
# (c) tilda 2018 - linux compat
if [[ ! -f "$HOME/.config/qwq-token" ]]; then
echo "Error: ~/.config/qwq-token not found."
exit
fi
# --- configurables
# directory in which to store screenshots
SCREENSHOT_DIRECTORY="$HOME/Screenshots"
# your owo token, read from ~/.config/qwq-token
TOKEN=$(tr -d "\n" < ~/.config/qwq-token)
# file path
DATE_FORMAT="%m-%d-%Y-%I:%M:%S-%p"
SAVE_PATH="$SCREENSHOT_DIRECTORY/$(date +$DATE_FORMAT).png"
# vanity url to output
VANITY="owo.sh"
# ---
if [[ $# != 0 ]]; then
file=$1
echo "Uploading..."
OWO_OUTPUT=$(curl -s -F "files[]=@\"$file\"" https://api.awau.moe/upload/pomf?key="$TOKEN" \
-H "User-Agent: $USER_AGENT")
echo "Uploaded! $OWO_OUTPUT"
FILE=$(echo "$OWO_OUTPUT" | $JQ_PATH -r ".files[0].url")
URL="https://$VANITY/$FILE"
echo -n "$URL" | pbcopy
echo "Copied to clipboard: $URL"
exit 0
fi
mkdir -p "$SCREENSHOT_DIRECTORY"
# screencap
maim -s "$SAVE_PATH"
# detect cancellation
if [[ "$?" == "1" ]]; then
echo "Screencapture cancelled."
exit 1
fi
echo "Saved to: $SAVE_PATH"
# upload
echo "Uploading..."
OWO_OUTPUT=$(curl -s -F "files[]=@\"$SAVE_PATH\";type=image/png" https://api.awau.moe/upload/pomf?key="$TOKEN" \
-H "User-Agent: qwq.sh (for linux!) (https://github.com/(slice|tilda)")
echo "Uploaded!"
# upload to owo
FILE=$(echo "$OWO_OUTPUT" | jq -r ".files[0].url")
URL="https://$VANITY/$FILE"
# copy
echo -n "$URL" | xclip -i -sel c -f | xclip -i -sel p
echo "Copied to clipboard: $URL"
# notify
notify-send "qwq" "your picture was uploaded: $URL"