Search code examples
macososx-snow-leopardgrowlscreensharing

How to detect when OS X Screen Sharing is active programmatically?


OS X does not make it obvious that you might've left a screen sharing session open -- and it's still actively broadcasting your session to these other computers. Does anyone know where Snow Leopard stores that the computer you're sitting at has an open screen sharing session?

If I could detect this file using a shell script every minute or so, then I could fire a Growl notification to let me know that I'm essentially being watched by this other computer (using the code snippet found here).

Otherwise, the only way to know now is to notice a very small icon on the top right of my screen that looks like binoculars (very hard to notice).


Solution

  • One way would be to use lsof to check for any established connections by AppleVNCServer

    lsof -a -i :vnc-server -sTCP:ESTABLISHED -c AppleVNCServer