I am trying to enumerate the screens via command line on OSX while on the loginscreen (using ssh).
But both [NSScreen screens]
and CGGetActiveDisplays
both return 0 screens. Is there another method of screen enumeration?
If you're an admin, System Prefs > Users & Groups > Login Options. Unlock the panel with the padlock icon, bottom left. Once you've disabled or changed the default login, then you can deal with whether or not to keep the old user's account.
To change these preferences, choose Apple menu > System Preferences, click Users & Groups , then click Login Options in the list on the left. Note: If the lock at the bottom left of the pane is locked , click it to unlock the preference pane.
Open the Displays preference pane, hold down the Option key, and click the Detect Displays button that appears where the Gather Windows button usually sits (at the lower-right corner of the pane).
A pre-login agent can enumerate displays using CGGetOnlineDisplayList.
I used the sample Apple code from here.
Modified it to link CoreGraphics, and added the following code to the applicationDidFinishLaunching
method:
CGDirectDisplayID displays[10];
uint32_t numDisplays = 0;
CGGetOnlineDisplayList(10, displays, &numDisplays);
for(uint32_t i = 0; i < numDisplays; i++)
{
[[LogManager sharedManager] logWithFormat:@">>> Found an online display!"];
}
if(numDisplays == 0)
[[LogManager sharedManager] logWithFormat:@"<<<<< No displays!"];
Following the documentation in the sample on how to view the logs, the following is printed on the login screen:
Jul 12 10:03:09 veeboxs-MacBook-Pro PreLoginAgentCocoa[3129] <Info>: Did finish launching begin
Jul 12 10:03:09 veeboxs-MacBook-Pro PreLoginAgentCocoa[3129] <Info>: Showing window with extreme prejudice
Jul 12 10:03:09 veeboxs-MacBook-Pro PreLoginAgentCocoa[3129] <Info>: Did finish launching end
Jul 12 10:03:09 veeboxs-MacBook-Pro PreLoginAgentCocoa[3129] <Info>: >>> Found an online display!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With