Skip to content

Instantly share code, notes, and snippets.

@BinRoot
Created December 21, 2013 19:56
Show Gist options
  • Select an option

  • Save BinRoot/8074153 to your computer and use it in GitHub Desktop.

Select an option

Save BinRoot/8074153 to your computer and use it in GitHub Desktop.
This script allows you the change the destination and name of your screenshots right after hitting printscreen. Bind your printscreen key to this script.
#!/bin/bash
# zshot allows you to easily change the filename and destination of each screenshot
# Dependencies: scrot, zenity
cd ~
if [ ! -d "Pictures" ]
then mkdir ~/Pictures
fi
if [ "$1" == "--rename" ]
then
OLDFILE=$2
NEWFILE=`zenity --file-selection --title "Name the screenshot" --filename "$2" --save --confirm-overwrite --file-filter='*.png'`
case $? in
0)
echo "\"$NEWFILE\" selected."
if [ "$NEWFILE" == "" ]; then
rm ~/Pictures/$OLDFILE
exit
fi
mv ~/Pictures/$OLDFILE $NEWFILE;;
1)
echo "No file selected.";
rm ~/Pictures/$OLDFILE;;
-1)
echo "An unexpected error has occurred.";
rm ~/Pictures/$OLDFILE;;
esac
exit
fi
if [ "$1" == "--selection" ]
then
scrot -s '%Y-%m-%d-%s.png' -e 'sleep 2 & mv $f ~/Pictures/ & zshot.sh --rename $f'
else
scrot -d 0 '%Y-%m-%d-%s.png' -e 'sleep 2 & mv $f ~/Pictures/ & zshot.sh --rename $f'
fi
@aksimhal

Copy link
Copy Markdown

excellent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment