Skip to content

Instantly share code, notes, and snippets.

@instance-id
Last active July 6, 2021 23:57
Show Gist options
  • Save instance-id/4cc914663d642b853318f581d85b37aa to your computer and use it in GitHub Desktop.
Save instance-id/4cc914663d642b853318f581d85b37aa to your computer and use it in GitHub Desktop.
Using Flameshot as the screenshot capture tool with imgur-screenshot in place of scrot/maim, etc
#!/usr/bin/env zsh
# --------------------------------------------------------------------------------------------
# -- Using Flameshot (https://github.com/flameshot-org/flameshot) as the capture application
# -- with imgur-screenshot (https://github.com/jomo/imgur-screenshot) to upload imgur account
# --------------------------------------------------------------------------------------------
# -- borrowed these from the imgur-screenshot script ----
# -- to describe the filename format and output path ----
declare -g FILE_NAME_FORMAT="%Y-%m-%d_%H-%M.png"
declare -g FILE_DIR="${XDG_PICTURES_DIR:-$HOME/Pictures/upload}"
declare -g IMGURSCRNSHT="/home/mosthated/.files/imgur-screenshot/imgur-screenshot.sh"
function main() {
img_file="$(date +"${FILE_NAME_FORMAT}")"
img_path="${FILE_DIR}/${img_file}"
# -- Use flameshot to capture the desired screeenshot area
# -- Hit enter once you select your screenshot area
flameshot gui -r >${img_path}
# -- Ensure the output was a real image, incase the capture was cancelled
# -- If file is not a real image, delete the file.
if file "$img_path" |grep -qE 'image|bitmap'; then
echo "File '$img_path' is valid"
else rm $img_path
fi
# -- Pass the image created by flameshot to imgur-screenshot for upload
if [ -f $img_path ]; then
echo $(${IMGURSCRNSHT} -l true ${img_path}) &!;
fi
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment