Skip to content

Instantly share code, notes, and snippets.

@7Ds7
Created January 5, 2023 02:38
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 7Ds7/8ace2125896c31e5838eebc559700733 to your computer and use it in GitHub Desktop.
Save 7Ds7/8ace2125896c31e5838eebc559700733 to your computer and use it in GitHub Desktop.
Flameshot bash script to self host your screenshots

The following script allows Flamehost screenshots to be uploaded for your own server and so you can self host your screenshots. I personaly like to use the applet Command Launcher to run the script for convenience.

What do you need

  • Flameshot itself
  • one ssh key that is allowed on your server without a password set
  • scp to copy the file to the server
  • notify-send to show notifications
  • xclip to copy the url upon file upload
  • Replace the values between [--- ---] ex: [---YourDomainName.com---] -> domain.com
  • copy the code block below to a .sh file with executable permissions ex: chmod +x fshot.sh
#!/bin/bash

filename=$(date "+%Y-%m-%d_%H_%M_%S".png)
url=https://[---YourDomainName.com---]/$filename
echo "Saving $filename"
# change to whichever binary you use, in the following line flatpak is used
flatpak run org.flameshot.Flameshot gui -r > ~/Downloads/fshot/$filename

# create the directory ~/Downloads/fshot first or change accordingly
if [[ ! -s ~/Downloads/fshot/$filename ]]; then
  echo "Empty removing file $filename"
  # notify-send should be installed in order to be notified
  notify-send  -i "applets-screenshooter-symbolic" "fshot - Aborted"
  rm  -f ~/Downloads/fshot/$filename
  exit
fi

echo "Uploading file $filename"
notify-send -i "applets-screenshooter-symbolic" "fshot - Uploading file" $filename

# you should have one ssh key that is allowed in the server without a password set for a user
scp ~/Downloads/fshot/$filename [---user---]@[---YourDomainName.com---]:~/[---HomeFolderOnDomain---]/
# xclip should be installed to copy the screenshot url
printf https://[---YourDomainName.com---]/$filename | xclip -selection c
echo "Copied to clipboard $url"
notify-send -i "applets-screenshooter-symbolic" "fshot - Copied to clipboard" $url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment