Skip to content

Commit bdd09cf

Browse files
committed
Add a warning if the process is not running within a Quartz GUI session.
1 parent 10a8300 commit bdd09cf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

GetWindowID.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ int main(int argc, char **argv)
2727
return -1;
2828
}
2929

30+
CFDictionaryRef session = CGSessionCopyCurrentDictionary();
31+
if (!session)
32+
fprintf(stderr,
33+
"Warning: %s is not running within a Quartz GUI session,\n"
34+
"so it won't be able to retrieve information on any windows.\n"
35+
"\n"
36+
"If you're using continuous integration, consider launching\n"
37+
"your agent as a GUI process (an `.app` bundle started via\n"
38+
"System Preferences > Users & Group > Login Items)\n"
39+
"instead of using a LaunchDaemon or LaunchAgent.",
40+
argv[0]);
41+
else
42+
CFRelease(session);
43+
3044
NSString *requestedApp = @(argv[1]);
3145
NSString *requestedWindow = @(argv[2]);
3246
bool showList = [requestedWindow isEqualToString:@"--list"];

0 commit comments

Comments
 (0)