Skip to content

Instantly share code, notes, and snippets.

@setzer22
Created August 26, 2017 17:58
Show Gist options
  • Save setzer22/f193c2d709ea191888d00474c8d1143f to your computer and use it in GitHub Desktop.
Save setzer22/f193c2d709ea191888d00474c8d1143f to your computer and use it in GitHub Desktop.
A small bash script to take a screenshot and save it to your Pictures folder. Requires maim
#!/bin/bash
if [ "$1" != "retry" ]; then
maim -s > /tmp/screenshot-tmp.png
fi
OUTFILE=$(zenity --file-selection --save --filename=/home/josep/Pictures/screenshot.png)
if [ $? -eq 0 ] && [ -f $OUTFILE ]; then
zenity --question --text "Image $OUTFILE exists. Do you want to overwrite?"
if [ $? -ne 0 ]; then
echo "IF"
sh $0 retry
else
echo "ELSE"
mv /tmp/screenshot-tmp.png $OUTFILE
fi
else
mv /tmp/screenshot-tmp.png $OUTFILE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment