luckman212 / dstat

CLI tool to query the screen sleep or lock status
1 stars 0 forks source link

Not working on Mac Mini M2 Pro running macOS 14.1.1 (23B81) #1

Open jtrott opened 11 months ago

jtrott commented 11 months ago

I tested by letting my screen turn off as it normally does, SSH'd into the mac mini and ran "dstat -s" - always returned 1. Also checked with "dstat -l" and that also always returned 1. I usually have 3 users logged in at all times on this Mac Mini.

luckman212 commented 11 months ago

Hmm. I've never tested it with 3 users logged in, so that could be the cause. I'll try to replicate this.

In the meantime, could you retest with only 1 user logged in and see if that works? How about no users logged in? (should return 4)

jtrott commented 11 months ago

Yep, reducing down to one logged in user from three does now return 0 for dstat -s and dstat -l.

luckman212 commented 11 months ago

I played around with this a bit, and am honestly stumped. I can reproduce the behavior you're seeing, when multiple users are logged in, the Quartz APIs like CGDisplayIsAsleep() and CGSessionCopyCurrentDictionary() do not return valid data if the dstat utility is run as a different user than the currently active user. I haven't found a workaround for this yet, but you may want to try my other variant of this, luckman212/display-is-sleeping. That does not detect Lock events, however, only Sleep.

jtrott commented 11 months ago

Looks like a bug in the framework then, maybe similar to @siracusas issues with windows that only happens when multiple users are logged in also. Good news, your other project seems to work fine regardless of the number of users logged in so I now have a light that is only on when my Mac screen is on again :)