I've written a very short program to collect some log files spit out by a 3rd party application. It zips up the files and emails them to me.
I'd also like to collect some information about the machine, and especially its graphics capabilities. Basically I'd like two pages from System Report, Hardware and Graphics/Displays. Gestalt is gone, so I'm looking for other solutions.
I found a solution here on SO to get the model of the machine using sysctlbyname, but it seems the values here are quite limited.
So, does anyone have a simple way to get GPU information?
Following on Mark's answer above, here's how to do it in (Swift) code. First, I used this solution to run a shell command:
func shell(launchPath: String, arguments: [String]) -> String
{
let task = NSTask()
task.launchPath = launchPath
task.arguments = arguments
let pipe = NSPipe()
task.standardOutput = pipe
task.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
let output: String = NSString(data: data, encoding: NSUTF8StringEncoding)! as String
return output
}
Then after a bit of playing around in system_profiler, I found I was interested in two keys, SPHardwareDataType
and SPDisplaysDataType
. That left me wondering where system_profiler is located, but which system_profiler
solved that. So I finally got what I needed thus:
let ai = shell("/usr/sbin/system_profiler", arguments: ["SPHardwareDataType", "SPDisplaysDataType"])
The results are a formatted string that is pretty much good-to-go as it is.