flameshot-org / flameshot

Powerful yet simple to use screenshot software :desktop_computer: :camera_flash:
https://flameshot.org
GNU General Public License v3.0
24.02k stars 1.53k forks source link

Trying to import a configuration file does absolutely nothing #3402

Closed BlueSky-fur closed 8 months ago

BlueSky-fur commented 8 months ago

Removed

mmahmoudian commented 8 months ago

I have no idea what zipline is, and we at Flameshot do not support anything but Imgur at this point. Also, what you imported is not Flameshot configuration. It is probably something that zipline folks have put together.

I've set file permissions and when I then try to import the config in Flameshot nothing happens,

I have no idea what you mean by "import the config". Can you send us screenshot of screen recording of what you do and what is the procedure you are going through?

I've also not seen any toggle to change where you want to upload.

there is nothing to be toggled. We do not support anything but Imgur. Maybe in future we do, but not at this point of time.

#!/bin/bash
flameshot gui -r > /tmp/ss.png;
curl -H "authorization: datvxxxxxxZUxxxxTY5OTEzxxxxxE5OQ" http://xxx.xxxxxxxxxxxx.xx:3000/api/upload -F file=@/tmp/ss.png -H "Content-Type: multipart/form-data" -H "Format: random" -H "Embed: true" | jq -r '.files[0]' | tr -d '\n' | pbcopy;

Is this the config you are talking about? if it is, then this is a Bash script that have been carelessly put together. Here is how you can improve it:

  1. Always use expanded version of arguments for readability. For instance for Curl, the -H should be --header, the -F should become --form; and for Flameshot the -r should be --raw.
  2. In Flameshot you don't need to redirect (i.e >) the output of Flameshot and save it to a file, you can ask Flameshot to write into a file directly: flameshot gui --path /blah/blah/blah.png
  3. it is a rookie mistake to hard-code the filename in /tmp/ because it might collide with some other file and over-write it, and you upload a wrong file. The solution is to as your computer to create a temp file, and then use that file
  4. if Flameshot is aborted, the curl part will run, which is potentially dangerous. unfortunately the current version of Flameshot does not change the exit code when screenshot is aborted ( #3321 ) , so we should try to improvise for now and check the output file
  5. you have an @ in the file path in the curl file that I don't know what it does. Perhaps that is the main cause of the error!!

Here is a better version (without changing the curl part apart from updating the file path):

#!/usr/bin/env bash

# create a temp file to avoid name collision
OUR_FILE=$(mktemp)

# take the screenshot
flameshot gui --path "${OUR_FILE}"

# check if aborted
if file "${OUR_FILE}" | grep --fixed-strings "${OUR_FILE}: empty"
then
    # solution taken from https://apple.stackexchange.com/a/115373/105984
    display notification "Screenshot was aborted, so we don't upload!" with title "Zipline upload script"
    exit 1
fi

# upload
curl -H "authorization: datvxxxxxxZUxxxxTY5OTEzxxxxxE5OQ" http://xxx.xxxxxxxxxxxx.xx:3000/api/upload \
     -F file="${OUR_FILE}"  \
     -H "Content-Type: multipart/form-data" \
     -H "Format: random" \
     -H "Embed: true" \
  | jq -r '.files[0]' \
  | tr -d '\n' \
  | pbcopy;

Does the monitor configuration matter with this issue?

No it does not. Also the link you provided does not work. It would be easier and safer if you post pictures directly into Github (just copy picture and paste inside the text box of Github)