             var singleDisplayMode = false
 
             
-            if  var displayIndex = Int(CommandLine.arguments[2]) {
+            if  var displayIndex = Int(argv[2]) {
                 if argc < 4 {
                     if displayIndex < 10 {
                         print("Specify display width")

        let error = CGBeginDisplayConfiguration(config)
        if error == .success {
            let option:CGConfigureOption = CGConfigureOption(rawValue:2) //XXX: permanently
            CGConfigureDisplayWithDisplayMode(config.pointee, display, mode, nil)
            let afterCheck = CGCompleteDisplayConfiguration(config.pointee, option)
            if afterCheck != .success {

func displayInfo(display:CGDirectDisplayID, mode:CGDisplayMode?) -> DisplayInfo? {
    var mode_ = mode
    if mode_ == nil {
        mode_ = CGDisplayCopyDisplayMode(display)
    }
    
    if let mode__ = mode_ {
