I tried this over on Apple's Developer forum, but no takers. Wonder if anyone here can help me.
I need my code to evaluate whether an external display is connected via a mini-display port. I'm thinking I should be able to do this by having a bash command that determines a boolean True/False value for the presence of a file. I'm just not sure what file I should be looking for, presumably something in /dev/
I've also noticed that WindowServer process sends messages to console on connection of the external display such as:
21/01/2013 04:24:11.647 WindowServer: Display 0x5b81c5c1: MappedDisplay Unit 1: Startup Mode 1920 x 1080, CGSThirtytwoBitColor, Resolution 1, IOMode 0x3e, IODepth 0x2, IOReturn 0x0
So perhaps another approach would be to have my script monitor the log files for those messages. However, not only am I not exactly sure how to do that without monitoring loads of useless log messages, but it also seems a bit clumsy. There must be a neater way to get the state of the video port, right??
Any suggestions on how to do this (anything in applescript, bash, objective-c, or plain-old c will do)?
Thanks in advance.