0

I'm using KUbuntu and I would like to take a regular screenshot (saved as PNG) of a VM I run under virtualbox. If possible do this outside the VM, every 30 min.

I've looked at scrot and spectacle. Neither seem to know what a 'window' is, meaning if it's covered by something else, or if I switched to another desktop, it won't be visible on the screenshot. (or I missed the option)

VirtualBox can use [View][Take screenshot], but how do I automate that ? Can I simulate pressing Host-E in the VM regularly somehow ?

I could record the VM session with [View][Recording] and then extract snaphots from the video, but we are talking about a week-long session.

I could set it up INSIDE the VM, but I'd rather not...

2
  • I could set it up INSIDE the VM, but I'd rather not... why not? If the window doesn't change places, you just need to screenshot a certain region of the screen, right?
    – Gantendo
    Commented Nov 27, 2023 at 14:42
  • Because someone else will be using it remotely and I don't want them to risk disabling it. I just wrote a hackish script with ImageMagick import -window and will post it when it's tested and cleaned up a bit.
    – dargaud
    Commented Nov 27, 2023 at 14:45

1 Answer 1

1

I managed to do it with ImageMagick. It only requires clicking on the window I want on start to select it, then it takes a screenshot every N minutes (script parameter $1):

#! /bin/bash
INTERVAL=${1:-1}    # Default 1 min
DESTDIR=~/Pictures/Snapshots

echo "Click on the window you want to screenshot every $INTERVAL minutes"

ID=$(xwininfo |
    sed -e 's/^ *//' | 
    grep -E "Window id" | 
    awk '{ print $4 }'
)

while true; do
    import -window $ID $DESTDIR/$(date +%Y%m%d-%H%M).png
    sleep $(($INTERVAL * 60))
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .