Skip to content

Instantly share code, notes, and snippets.

@Sparkenstein
Last active December 19, 2018 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sparkenstein/fe8292be826db899bca5ef974a722dfb to your computer and use it in GitHub Desktop.
Save Sparkenstein/fe8292be826db899bca5ef974a722dfb to your computer and use it in GitHub Desktop.
flameshot post screenshot custom upload hook

Just add the following files at given locations: all credits to @guihkx for solving this issue

save your-uploader.desktop to ~/.local/share/applications/. edit it accordingly. make note of Exec=xxx section. it should be the name of next file save myuploader to either ~/.local/bin/my-uploader or anywhere in your $PATH. edit it accordingly. most probably you don't need to change anything besides the curl command on L20

after saving both files, run update-desktop-database ~/.local/share/applications and chmod a+x /path/to/myuploader

Then, when you take a screenshot with flameshot, just click on icon that says "Choose an app to open the capture". You will see your custom application there Click on it, it will upload the file, and copy the response of server to clipboard.

#!/bin/bash
# Dependencies: curl, notify-send, xclip
function _notify()
{
notify-send --expire-time 2000 \
--app-name 'your-app(anything)' \
--icon 'flameshot' \
"$1" "$2"
}
if [ ! -f "$1" ]
then
_notify 'My uploader' 'Error: Invalid screenshot file.'
exit 1
fi
_notify 'My uploader' 'Uploading screenshot to your website ...'
res=$(curl --silent --show-error \
-F "file=@$1" \
http://0x0.st 2>&1)
if [[ ${res:0:7} == 'http://' || ${res:0:8} == 'https://' ]]
then
echo -n "$res" | xclip -selection clipboard
_notify 'My uploader' 'Success! The link was sent to your clipboard'
else
_notify 'My uploader' "Error: $res"
fi
[Desktop Entry]
Type=Application
Name=your private uploader
Categories=Graphics
Comment=Uploads screenshots to your website and copy the link
Icon=cloud-upload
Exec=myuploader %u
Terminal=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment