Cannot retrieve contributors at this time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
#!/bin/bash | |
upload_url=https://api.tempfiles.download/upload/ | |
screenshot_path=~/Pictures/Screenshots | |
screenshot_name="screenshot_$(date +%s).png" | |
remove=false | |
error() { | |
notify-send "$1" | |
exit 1 | |
} | |
[[ -d "$screenshot_path" ]] || mkdir "$screenshot_path" | |
full_path="$screenshot_path/$screenshot_name" | |
[[ "$1" == "window" ]] && import -window root "$full_path" || import "$full_path" | |
[[ "$1" == "local" ]] && notify-send "Screenshot saved!"; exit 0 | |
data=$(curl -s -X "POST" -F "[email protected]$full_path" "$upload_url") | |
if [ -f "$full_path" ]; then | |
[[ "$remove" == true ]] && rm "$full_path" | |
else | |
error "Error creating screenshot." | |
fi | |
[[ -n "$data" ]] && url=$(echo "$data" | jq -r .url) || error "No response from TempFiles" | |
echo "$url" | xclip -selection clipboard | |
notify-send "Screenshot URL copied!" | |
exit 0 |