cirruslabs / macos-image-templates

MIT License
207 stars 56 forks source link

enable screencapture #162

Closed edwinvanderham closed 2 months ago

edwinvanderham commented 2 months ago

I would love to be able to take a screenshot of a running VM using the screeencapture command. This seems to work fine, however I always get a 'blank' screen showing only the menu bar but no visible apps. The reason for this is probably a system security setting that has to be enabled?

Is this something that could be added to the vanilla or base images?

fkorotkov commented 2 months ago

Could you please provide steps to reproduce? Which version of VM do you run? What kind of arguments do you pass to tart run? Do you press Cmd+Shift+3 on the host?

fkorotkov commented 2 months ago

I tried to run ghcr.io/cirruslabs/macos-ventura-base:latest image:

tart clone ghcr.io/cirruslabs/macos-ventura-base:latest ventura-base
tart run ventura-base

And was able to take a screenshot and all information was there.

edwinvanderham commented 2 months ago

I was trying this on macos-sonoma-vanillla

fkorotkov commented 2 months ago

Ran the same with ghcr.io/cirruslabs/macos-sonoma-base:latest and still can take screenshots from the host. How exactly are you running the VM?

edwinvanderham commented 2 months ago

I only have ssh access to a macmini with tart installed. On the macmini I do the following

tart clone ghcr.io/cirruslabs/macos-sonoma-vanilla:latest sonoma-vanilla
tart run sonoma-vanilla &
ssh admin@$(tart ip sonoma-vanilla) 'screencapture /tmp/capture.png'
scp admin@$(tart ip sonoma-vanilla):/tmp/capture.png .

This gives me a capture.png file showing an empty desktop. I think this is because there is a dialog showing to the admin user asking to grant the ssh daemon access to the screen

fkorotkov commented 2 months ago

Seems screencapture over SSH on a remote host is a known issue and it's not a permissions issue. I didn't find a viable workaround on Google though. Doesn't seem like we can do anything about it with Tart itself or VM templates and the issue is with how ssh is running.

edigaryev commented 2 months ago

This gives me a capture.png file showing an empty desktop.

Have you tried running the same command on the host?

It gives an empty desktop for me too on the host machine, so I'm not even sure if this is VM related.