Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX: Enumerate screens while on Login Window

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?

like image 439
Nidhoegger Avatar asked Jun 29 '17 09:06

Nidhoegger


People also ask

How do I see all the Users on my Mac login screen?

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.

How do I change my login preferences on Mac?

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.

How do you gather Windows on a Mac?

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).


1 Answers

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!

like image 100
TheNextman Avatar answered Nov 15 '22 21:11

TheNextman