Wednesday, February 26, 2014

Linux screenshot solution

I often work on different projects, switch between projects all the time, and need to take screenshots. If you’re in a similar situation you may find this useful.

1. Install scrot
sudo apt-get install scrot
2. Create a file with your current project name. it can also be an environment variable but I find the file solution easier to work with.
echo MyProject > $HOME/.current
3. Create a shell script with the following contents:
#!/bin/bash
PROJECT=$(cat ${HOME}/.current)
DATE=$(date +%Y-%m-%d.%s)

if [ ! -d "${HOME}/projects/$PROJECT/shots" ]; then
    mkdir -p "${HOME}/projects/$PROJECT/shots"
fi

scrot "${HOME}/projects/${PROJECT}/shots/${PROJECT}_${DATE}.jpg" -s -q 90
4. You can create a lancher to this shell script that you can put in your launcher bar or whatever:
bash $HOME/screenshot.sh
Your screenshots will be saved for each project under the appropriate folder. Don’t forget to update your project file whenever you switch projects.

No comments:

Post a Comment