Determine if WindowServer is available?

前端 未结 1 482
闹比i
闹比i 2021-01-13 01:47

I\'m writing a framework for OS X that may be used by applications with or without a connection to the OS X WindowServer (i.e. both GUI apps and command-line apps run via, e

相关标签:
1条回答
  • 2021-01-13 02:26

    There's an environment variable named SECURITYSESSIONID that is set by loginwindow.app and get's passed to the user's applications. The variable is not set if you login via ssh. It serves as kind of a handle to talk to the window server.

    Problem: The existence of this variable does not mean that this user currently controls the window manager (think fast user switching).

    There's a function called CGSessionCopyCurrentDictionary in the ApplicationServices framework which looks promising:

    Return Value: A window server session dictionary, or NULL if the caller is not running within a Quartz GUI session or the window server is disabled. You should release the dictionary when you are finished using it. For information about the key-value pairs in this dictionary, see "Window Server Session Properties."

    0 讨论(0)
提交回复
热议问题