SystemConfiguration.framework?

You can:

- retrieve the current uid,gid, user name with SCDynamicStoreCopyConsoleUser
- be notified via a C callback when the console user changes
(SCDynamicStoreCreate, SCDynamicStoreKeyCreateConsoleUser(),
SCDynamicStoreSetNotificationKeys, SCDynamicStoreSetDispatchQueue or a
more classic runloop source) and then then call
SCDynamicStoreCopyConsoleUser.

Note that when the login window is displayed, the current user name is
"loginwindow".

I've never checked which uid or user name was returned when the screen
is locked.


On Fri, Apr 21, 2017 at 9:57 AM, Uli Kusterer
<witness.of.teacht...@gmx.net> wrote:
> Hi,
>
> I have an application (think hardware driver) that runs as a particular (GUI) 
> user. Now, if that user is switched out using Fast User Switching or the 
> screen lock has engaged, I want to prevent the driver from working (as the 
> user sitting in front of the computer with access to the hardware is 
> obviously not them).
>
> The only documented API I've found is 
> NSWorkspaceSessionDidResignActiveNotification etc., but this doesn't help me 
> because it only notifies me when the state changes, it doesn't let me obtain 
> an initial state (I suppose I could assume if I'm running as a user, my 
> session is active, but would prefer actually knowing).
>
> I've also found that CGSessionCopyCurrentDictionary() contains an 
> undocumented key that lets me know whether the screen lock is engaged, but 
> that reports the screen as not locked when the user is still logged on, but 
> switched out using fast user switching.
>
> Is there any official, supported way to determine whether the user my app is 
> running as actually owns the screen and screen lock is not engaged that I 
> could use for this purpose? Since I only need to know the current state when 
> the user actually triggers my device, a polling API would be fine.
>
> Cheers,
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/dev.iceberg%40gmail.com
>
> This email sent to dev.iceb...@gmail.com



-- 
Packaging Resources - http://s.sudre.free.fr/Packaging.html
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to