Desktop Picture Script Not Working on a Blind Server

I have a script to take a picture of the desktop of my blind server (MM 2018) that is not working if I am not logged in as in connected to it. If I am logged in and observing the screen it works fine. The MM has a dongle (Brand MI TV) in the screen port. I needed to do this since screen sharing (via remote management) does not work good without a monitor connected.

So, if I run the script while connected it works as should. As soon as I disconnect it stops working. See pic for the notification I get.

Any idea as to why?

This is the part of the script that makes the picture.

-- Activate windows

tell application "Finder"
   set visible of every process whose visible is false and name is not "Finder" to true
end tell

delay 3 -- remove if not needed however it seems to be needed to make it run properly

-- Make DT pic

set dFolder to "~/Desktop/"
do shell script ("mkdir -p " & dFolder)
set i to 1

repeat 1 times -- interval put in any repeat you like
   do shell script ("screencapture " & dFolder & "DT-Server-Pic-" & i & ".png")
   delay 1 -- wait for xx seconds - remove if not needed
   set i to i + 1
end repeat

-- Send a message - here follows the sending part of the script

Screenshot 2022-12-31 at 08.54.07

My best guess is that there’s no Video available to capture…

I could agree with that seems a logical conclusion. So the question is how to work around that.

See in the control panel it sees the dongle as a screen. If I remove it it reverts to build-in display (see pics and of course the MM has no display build in). One would think the MM sees a screen and screenshots should work.

I’m guessing there’s no video signal when there’s not a screen when using that dongle.

I have seen dongles specifically made to work with headless servers, although I’ve not used one myself.

https://www.bhphotovideo.com/c/product/1213945-REG/newertech_nwtadp4khead_hdmi_headless_video_accelerator.html

Thanks for the link.

I have done some more experimenting. Tried 2 different brand dongles, no success.

Found Shottr on the internet, installed it and it makes perfect pictures of the screen and on its own (as in when I am not logged in). It can be scripted with keyboard commands. Not the most elegant solution but it works.

Strange or? I do not understand why one works and the other not.

Interesting…

Glad you found a solution!

My best guess is that the frame buffer is a dynamic driver that updates the screen when it’s connected.

If a computer is started in headless mode and no screen is connected – the frame buffer is 0 in other words missing value. In that case I guess the system needs a virtual display driver.

OK Interesting thought. But if I connect the dongle and disconnect I see that the control panel is responding (see pics above).

Again the dongle is seen in the control panel.

However is there maybe a terminal command that could help it change its mind? Set it to 1?

Celebrated too early…

It works by itself shortly after I disconnect from remote management. but it did not run as scheduled (twice not) 2 hours later and 14 hours later.

The mystery continues.