7

If I would like to select a window for scrot this could be easily done with:

scrot -s name.jpg

But if I want to ask scrot to keep taking screenshots from a selected window, then I don't know how to do this. The following is what I tried:

#!/bin/sh
while true
do
   scrot -s "$(date)".jpg
   sleep 5
done

The problem with the above is: after every 5 seconds I have to tell scrot which window by clicking it.

If only I could pass the window by clicking it only once the first time it would be perfect.

If not, could I tell scrot which window by telling it the window name?

Edit: I also want it to work even when the window is minimised. How to do this?

Inspired_Blue
  • 601
  • 2
  • 11
  • 26

1 Answers1

8

From man scrot:

       -u, --focused
            Use the currently focused window.

So you could just change your script like so:

#!/bin/sh
while true
do
   scrot -u "$(date)".jpg
   sleep 5
done

However this will start taking screenshots as soon as the script is started, which is probably undesired; this would be a bit more user-friendly, as it will start taking screenshots only after the user has manually selected a window:

#!/bin/sh
scrot -s "$(date)".jpg
while true
do
   sleep 5
   scrot -u "$(date)".jpg
done
kos
  • 41,268