Skip to content

Instantly share code, notes, and snippets.

@LunaSquee
Created May 17, 2018 18:24
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 LunaSquee/a002e862efe6b5214f6a9bbe072a485b to your computer and use it in GitHub Desktop.
Save LunaSquee/a002e862efe6b5214f6a9bbe072a485b to your computer and use it in GitHub Desktop.
Screenshot script
#!/bin/bash
# Depends: scrot, feh, gnome-screenshot, zenity, xclip
outputDir="~/Pictures"
output="Screenshot_`date +"%y-%m-%d-%T"`.png"
tmp=$(mktemp -u); scrot -e "mv \$f $tmp"; feh -F $tmp & gnome-screenshot -a -f $outputDir/$output && rm $tmp && pkill -P $$
# Rewritable upload command
# Must echo an URL
imageupload() {
# Command here
echo ""
}
image() {
# Ask user for next action
action=$(zenity --list --title="Screenshot successful" --text="What would you like to do with this image?" --column "Action" --column "Description" 1 "Copy URL to Clipboard" 2 "Copy Image to Clipboard" 3 "Open Image in GIMP" 4 "Delete Image" 5 "View Image")
if [[ $? == 1 ]]; then
exit 1
fi
case $action in
1)
PUBURL=$(imageupload "$1")
echo $PUBURL | xclip -selection clipboard
notify-send 'Screenshot' 'URL copied to clipboard!' -t 3500 -i dialog-information
;;
2)
xclip -selection clipboard -t image/png -i "$1"
notify-send 'Screenshot' 'Image copied to clipboard!' -t 3500 -i dialog-information
;;
3)
gimp "$1"
image "$1"
;;
4)
rm "$1"
;;
5)
xdg-open "$1"
image "$1"
;;
*)
esac
}
if [[ -e "$outputDir/$output" ]]; then
image "$outputDir/$output"
else
notify-send 'Screenshot' 'Screenshot cancelled!' -t 3500 -i dialog-error
exit 127
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment