5

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?

7

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
  • 2
    Oh! A feature a want is that it should record a screen even when it is minimised. Is that possible? – Inspired_Blue Jan 1 '16 at 2:27
  • 1
    @Inspired_Blue No. There's no relevant option in the man page, so no, at least not with scrot. Wouldn't know which alternative to suggest though. – kos Jan 1 '16 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.