site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Unfortunately, this lists all logged-in user using a GUI session, but won't tell which one is currently active/front. - Antoine On Aug 20, 2010, at 10:09 PM, Dave Keck wrote:
I use the utmpx APIs to determine the existing console users from a daemon process; see the UTXplorer example (which I believe Quinn wrote?).
==========
#import <utmpx.h>
- (NSSet *)userNamesForExistingUserSessions {
struct utmpx *currentEntry = nil; NSMutableSet *result = nil;
result = [NSMutableSet set];
setutxent();
while (currentEntry = getutxent()) {
/* Verify that we have a user and that currentEntry's session is a GUI ('console') session */
if (currentEntry->ut_type == USER_PROCESS && !strcmp(currentEntry->ut_line, "console")) [result addObject: [NSString stringWithUTF8String: currentEntry->ut_user]];
}
endutxent();
return result;
}
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com