2

I'm new to using scrot. I know how to take screenshots by typing the code scrot Image.jpg. I want to take continuous screenshots without the use of typing the code everytime on the Terminal.

Is there a way to do so and if so, what should I do in order to do so?

2 Answers2

3

Scrot doesn't allow taking multiple screenshots in batch. However, you can use bash (or any other languages') loop feature to achieve this.

Here is how I took 10 screenshots in files named screenshot_n.png (where n is the sequence number`) in delay of 1 seconds each.

for i in $(seq 1 10); do sleep 1; import -window root screenshot_$i.png; done

I used the import tool here. It came from imagemagick. You can use scrot in place of import. Change the sleep 1 line to match your desired delay. Check import man page for more details.

You can use it in bash-function also like this

function shot()
{
    for i in $(seq 1 $1); 
    do 
        sleep 1; 
        import -window root screenshot_$i.png; 
    done
}

Save it in .bashrc file. You can use it in bash with this syntax shot n, where n is the number of screenshot you need to take`

Here is another command that uses scrot. I used scrot's built-in delay feature instead of bash sleep command here. Check scrot man page for more details. You can use this in bash-function as before.

for i in $(seq 1 10); do scrot -d 1 screenshot_$i.png; done

You can check the following question to get suggestions for other screenshot taking tools from command line

Anwar
  • 76,649
  • 1
    Anwar, you can improve your answer if you make it into a bash function, and pass an integer , so that in seq 1 $1 it can run from 1 to x number of screenshots. Also, please don't use backticks, use $(seq 1 $1) , it's far better for readability – Sergiy Kolodyazhnyy Nov 05 '16 at 09:11
1

Would not be this good enough?

watch -n 5 "scrot peepshow.png" # snaps the screen every 5 seconds

or if you want to save the snapshots

watch -n 3 "scrot peepshow\$(date +%Y-%m-%d_%H-%M-%S).png"

"Off you go" with CTRL-C.

xerostomus
  • 990
  • 9
  • 20