New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Run script on save #357

ronjouch opened this Issue Sep 26, 2018 · 6 comments


None yet
4 participants
Copy link

ronjouch commented Sep 26, 2018

I like to pass my screenshots through pngquant, for excellent lossy-but-I-don't-care-for-screenshots compression.

I do this manually each time, but it would be great if Flameshot had a Run script on save option.

  • It would require configuration of a path to a script/binary.
  • After screenshot save, if configured and if the path provided exists and is executable, the script/binary would be called with the full path passed as argument.

This comment has been minimized.

Copy link

lupoDharkael commented Sep 26, 2018

You can use the command line interface of flameshot to do that. Here is an example:
flameshot gui -r > myfile.png && do stuff with myfile.png


This comment has been minimized.

Copy link

ronjouch commented Sep 26, 2018

@lupoDharkael thanks for the fast feedback 🙂.

I wanted to like flameshot gui -r, but it's annoying as it results in two pngs being written 😕: the one produced by the redirect, and the default one named after the naming configuration. If passing flag -r I'd expect the GTK "save as" dialog to not popup.


This comment has been minimized.

Copy link

lupoDharkael commented Sep 26, 2018

You are right, I guess it would be a good idea to have optional scripts called after the capture is done (and passing the path of the image to the script as an argument)


This comment has been minimized.

Copy link

drm86 commented Oct 9, 2018

This could be a nice feature, for now I have to use a crappy shell script to do things like upload the result screenshot to other service different than imgur (like This is what I'm using now and this script is binded to Print Screen key:



mkdir $PATH_IMG &&

RESULT_CAP=$(flameshot gui -p $PATH_IMG -r > $PATH_IMG/img.png && head -n 1 $PATH_IMG/img.png)

if [[ $RESULT_CAP != "screenshot aborted" ]] ; then
    RESULT_CURL=$(curl -F c=@$PATH_IMG/img.png
    echo $RESULT_CURL | xclip -i -rmlastnl -selection clipboard
    notify-send "Captura subida a: "$RESULT_CURL "El enlace copiado en el portapapeles" -u normal -t 7500 -i clipboard

rm -rf $PATH_IMG;

Other problem with scripting is there's no Exit Codes present in this application, so the only way I can manage is reading the first line of the raw output file.



This comment has been minimized.

Copy link

chelobaka commented Oct 10, 2018

I'm looking for a program to replace outdated and broken Shutter, and Flameshot could be my choice if it could pass a screenshot to a custom script. (I need to upload images over WebDAV and copy URLs to clipboard.)

UI part of this feature could be done like this:

  1. In the settings user adds a script, gives it a name. Several scripts can be added.
  2. In screenshot window for each user script extra button is created with script name shown, when cursor is over the button.

This comment has been minimized.

Copy link

ronjouch commented Oct 10, 2018

I gave up on Flameshot and other do-it-all screenshot tools. No harsh feelings on Flameshot at all, at the end of the day I think it's just too much to ask to a single free niche Linux app. I prefer to delegate [screenshot, edition, automation] to dedicated tools, tied together by a customizable script. Here's my current script that:

  1. Makes a screenshot, using the minimal gnome-screenshot (but replace with whatever you like).
  2. Optionally passes it to Inkscape for powerful editing.
  3. Runs pngquant on it.
  4. Saves for archival in a dedicated folder.
#!/usr/bin/env sh

date=$(date +%Y-%m-%d-%H:%M:%S)

gnome-screenshot --area --file="$file_orig"
# or install & use maim, it's better as the pointer and delay options
# are not exclusive, so you can have the cursor in the screenshot
# maim --delay=1 --select "$file_orig"
if [ ! -f "$file_orig" ]; then exit 1; fi

title="$(zenity --entry --title='Screenshot' --text='Optionally name the screenshot (start with "i " to edit in Inkscape):' --ok-label='Save screenshot')"
if [ $? -ne 0 ]; then exit 1; fi

if [ "${title#i }" != "${title}" ]; then
  inkscape "$file_orig"
  title="${title#i }"

folder="$(xdg-user-dir 'PICTURES')/Screenshots"
if [ ! -d "folder" ]; then
  mkdir -p "$folder"

if command -v pngquant > /dev/null; then
  if [ -n "$title" ]; then

  pngquant --strip --force --output "$file" "$file_orig"
  # zopfli too slow, disabled but enable it if you want to shave even more bits from your PNGs
  # if command -v zopflipng > /dev/null; then zopflipng -y "$file" "$file"; fi
  zenity --warning --text='Please install pngquant'
rm "$file_orig"

nautilus "$folder"

I bind this to PrtScr using GNOME Shell's native keybinding mechanism. ❤ ensues. Improvements welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment