Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Change Agent

macrumors regular
Original poster
Oct 24, 2018
143
9
I want to take a screenshot of the MM desktop (MM 2018 running OS13) at intervals and have it sent via email. So, I have written a script that does this. Purpose is to see what is going on when the MM is unattended. The MM is used as a server so runs 24/7.

The script work fine if I am logged in via another computer. It does not work if I am not logged in. So, I am pretty sure it is not the script (see pic of error below).

My suspicion is that somehow the MM notices that nobody is there (so to speak) and as such the screenshot does not work.

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 properly without a monitor connected. The dongle does the job for that perfectly (see also the pics of error below of the control panel).

The Dongle is present during the booting process, so one would think the Mac thinks there is a screen. However, does not seem to be recognised as a screen if I want to make a screenshot.

Does anybody have an idea as to how to trick the system in to thinking there is somebody watching on a screen and so make the picture work? Again, logged in it works, not logged in it does not.

Here the pics of the control panel after I connect or disconnect the dongle.

2.jpeg


3.jpeg


Here the pic for the notification I get when the script runs, and it does not send a screenshot.

1.png


I look forward to your thoughts.
 
Last edited:
  • Like
Reactions: uller6

uller6

macrumors 65816
May 14, 2010
1,045
1,686
This is a very interesting question OP! I also run a MM server headless with a dongle so am curious about a solution, but don’t have one myself.
 

Change Agent

macrumors regular
Original poster
Oct 24, 2018
143
9
that is two of us who would like to know. let's hope somebody has a suggestion.
 

Basic75

macrumors 68000
May 17, 2011
1,992
2,335
Europe
Does "MM" stand for "Mac mini"? If yes, why?

When no user is logged in then there is nothing to screenshot except for the login screen.

What is preventing you from doing a normal graphical login on the machine to keep the user session open at all times? Is the local session terminated when you disconnect from VNC or Screen Sharing after logging in?

Another question is, what information are you gathering, and is it not possible to gather the same information from your script by using other Terminal commands instead of going the graphical way?
 

Change Agent

macrumors regular
Original poster
Oct 24, 2018
143
9
Does "MM" stand for "Mac mini"? If yes, why?
is often used as a abbreviation. so we use it too.

When no user is logged in then there is nothing to screenshot except for the login screen.

There is a user logged in.

What is preventing you from doing a normal graphical login on the machine to keep the user session open at all times?

That is what I do. I log in romeotely and I log out again over screensharing. But the user on the MM is still logged in.

Does "MM" stand for "Mac mini"? If yes, why?

Not sure what you mean here.

Another question is, what information are you gathering, and is it not possible to gather the same information from your script by using other Terminal commands instead of going the graphical way?

I like to have a picture send of the running application(s) to see if there is a message because something did not work. I run about 30 applescripts and sometimes one hangs. This might block the other scripts from running.

I do not think (or know how to) that this can be done via terminal. Or can it?

And thanks for posting your thoughts.
 

Chancha

macrumors 68020
Mar 19, 2014
2,113
1,906
Have you looked into using "Apple Remote Desktop", the client software app that is. It has a few administrator centered monitoring reporting tools which may help your case.

That said, I don't think it fundamentally changes the way the VNC server works (that is, your mini's macOS built-in screen sharing ability). So if ultimately you still need a screenshot, then the behaviour on this mini probably won't change since a screenshot involves the graphics driver and it is hardware driven (which you already know, as with your MI dongle).

You may also look into 3rd party VNC solutions where it may have a completely different GUI behaviour, like Jump Desktop.
 

Change Agent

macrumors regular
Original poster
Oct 24, 2018
143
9
Have you looked into using "Apple Remote Desktop", the client software app that is. It has a few administrator centered monitoring reporting tools which may help your case.
Yes I did, at about 100€ it is to expensive an experiment and overkill I think.

That said, I don't think it fundamentally changes the way the VNC server works (that is, your mini's macOS built-in screen sharing ability). So if ultimately you still need a screenshot, then the behaviour on this mini probably won't change since a screenshot involves the graphics driver and it is hardware driven (which you already know, as with your MI dongle).
OK good logic.

You may also look into 3rd party VNC solutions where it may have a completely different GUI behaviour, like Jump Desktop.
I have a look at that. Any other suggestions for software?

Thanks.
 

Chancha

macrumors 68020
Mar 19, 2014
2,113
1,906
Yes I did, at about 100€ it is to expensive an experiment and overkill I think.


OK good logic.


I have a look at that. Any other suggestions for software?

Thanks.
I have personally only have experience with those two, ARD for Mac-to-Mac, then Jump for when accessing from iOS or really remote location with extremely high ping (their protocol is a lot more tolerant with high latency).

I just remembered some screenshot related experience: on remote-accessing an old macOS like Mojave or older, somehow initialising a screen capture remotely will give a blank image (same as what you try to do but manually). I figured this is probably graphics driver related since this happened with a Mac mini 2012 running headless. At that time my solution was simple, I then initiated the screenshot capturing on the ARD client-side, because WYSIWYG so this way it worked.

So while it is not an ideal solution but I bet you could in theory setup a 2-step screen capturing routine, where the actual capturing happens on a remote machine instead of the host mini. You could probably even do this with a VM or something and it can have a constantly connected VNC session to the mini within the same LAN so there's minimal network issue.
 

Change Agent

macrumors regular
Original poster
Oct 24, 2018
143
9
Thnaks for thinking with me.

I just remembered some screenshot related experience: on remote-accessing an old macOS like Mojave or older, somehow initialising a screen capture remotely will give a blank image (same as what you try to do but manually). I figured this is probably graphics driver related since this happened with a Mac mini 2012 running headless. At that time my solution was simple, I then initiated the screenshot capturing on the ARD client-side, because WYSIWYG so this way it worked.
Yes that is more or less my experience. And (I use a AppleScript) if i set it with a 5 minute delay after I log out it still works. But an hour later not.

So while it is not an ideal solution but I bet you could in theory setup a 2-step screen capturing routine, where the actual capturing happens on a remote machine instead of the host mini. You could probably even do this with a VM or something and it can have a constantly connected VNC session to the mini within the same LAN so there's minimal network issue.
That would be posible if I am in the smae network but the reason for doing this is that the MM is running allone in its own neterk. It is at these times I like a screenshot jsut to see all is well (or not as may be),
 

Boyd01

Moderator
Staff member
Feb 21, 2012
7,716
4,599
New Jersey Pine Barrens
on remote-accessing an old macOS like Mojave or older, somehow initialising a screen capture remotely will give a blank image (same as what you try to do but manually). I figured this is probably graphics driver related since this happened with a Mac mini 2012 running headless.

Just tried this on my headless 2012 Mini Server running Catalina. Screenshot works exactly as expected when connected with the standard Apple Screen Sharing. Also works correctly with screen sharing on my 2014 Mini media server running Mojave.

And (I use a AppleScript) if i set it with a 5 minute delay after I log out it still works. But an hour later not.

You have probably already thought of this, but just in case... do you have the "display" on the headless Mini set to never sleep?
 

Change Agent

macrumors regular
Original poster
Oct 24, 2018
143
9
Just tried this on my headless 2012 Mini Server running Catalina. Screenshot works exactly as expected when connected with the standard Apple Screen Sharing. Also works correctly with screen sharing on my 2014 Mini media server running Mojave.

That is if you are logged in remotely, yes? If so that would be the same as in my case. I suspect you did not try with a script that runs when nobody is logged in?

You have probably already thought of this, but just in case... do you have the "display" on the headless Mini set to never sleep?

No I had not. So just turned that on. Set the script to fire an hour later so let's see what happens. A simple thought but could do the trick.
 
  • Like
Reactions: Boyd01

Chancha

macrumors 68020
Mar 19, 2014
2,113
1,906
Screenshot 2023-01-13 at 11.55.48.png


To clear things a little:
The scenario I brought up with remote screenshot not working correctly was only an anecdotal example, it only happens with this machine and this instance of macOS which I thought was relevant to OP's issue due to how it behaves.

I am attaching two screens to illustrate what happened: the remote machine is a headless mini 2012 running Mojave with Mail.app opened. The client machine used to access is a Mac Studio running latest Monterey with Apple Remote Desktop app also latest. The above screenshots: left is via client-side ARD, and right is captured within the server-side Mojave. As you can see all black text are gone, including GUI elements within Mail.app and the top menu bar. Even iStat Menus have some elements missing. To me this is clearly a graphics driver issue going on. The remote Mojave instance is running headless without a real display connection and a dongle, so even though the VNC is active and we clearly are getting a screen drawn and is working correctly via the ARD client, but, the screen capturing utility within that server-side macOS seems to rely on different ways to get the final rendered image.

The whole point I was trying to make in regards to OP's situation was that, there can be a number of reasons keeping a remote screenshot to work correctly, and with VNC somehow a solution is to then skip the server machine, instead use the client machine to do that instead.

I think screenshots just sometimes don't work like this, but not always, it is unknown to me what dictates this behaviour. I have an almost exact same model of another mini 2012 (with just a lower clocked i7 but everything the same), it runs Catalina and its screen shot capturing does not behave like this, it works perfectly.
 

Change Agent

macrumors regular
Original poster
Oct 24, 2018
143
9
Thanks for taking the trouble with your extensive answer.

I think screenshots just sometimes don't work like this, but not always, it is unknown to me what dictates this behaviour. I have an almost exact same model of another mini 2012 (with just a lower clocked i7 but everything the same), it runs Catalina and its screen shot capturing does not behave like this, it works perfectly.
It is interesting you say this because with my old mini (2012) it worked if I used a third party app to make the screenshot. With this one I can not get it to work with anything.

I have also been thinking if it would be possible to use a terminal command to trick the mini in to believing there is a screen attached.

FYI, I added the dongle because if it is not attached I get strange resolutions if I log in remotely. Do you not? So somehow the dongle does something to the graphic interface. See also the pictures above of how the control panel responds.
 

Chancha

macrumors 68020
Mar 19, 2014
2,113
1,906
Thanks for taking the trouble with your extensive answer.


It is interesting you say this because with my old mini (2012) it worked if I used a third party app to make the screenshot. With this one I can not get it to work with anything.

I have also been thinking if it would be possible to use a terminal command to trick the mini in to believing there is a screen attached.

FYI, I added the dongle because if it is not attached I get strange resolutions if I log in remotely. Do you not? So somehow the dongle does something to the graphic interface. See also the pictures above of how the control panel responds.
Yes different software definitely uses different methods to get the image, thus one may have problems while the other not.

Then depending on certain makes of Macs, with or without a display or even a dummy one, you get close to no option to resolution or it sticks to a certain default. In my experience with headless minis, it seems it is always 1280x1024, unless you go very far back with much older Mac OS then I believe it was 1024x768 instead. With the presence of a dongle, or an attached display even if it is off, the OS gets to set the resolution to the last time it used the display, until a reboot I think. For instance I have a media mini that has its HDMI permanently connected to an AV receiver which is never turned on until we need video. So whenever I remote into it to just play audio for instance, I always still get 1920x1080 full HD which is what that HDMI connection is supposed to be at when active. In fact I can unplug the HDMI and the resolution won't change, until the machine reboots that is.
 

Change Agent

macrumors regular
Original poster
Oct 24, 2018
143
9
Chancha thanks, an intersting puzzle is it not. My resolution etc. changes as soon as I pull the dongle or plug it in.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.