diff --git a/BrewServicesMenubar.xcodeproj/xcuserdata/andrew.xcuserdatad/xcschemes/BrewServicesMenubar.xcscheme b/BrewServicesMenubar.xcodeproj/xcuserdata/andrew.xcuserdatad/xcschemes/BrewServicesMenubar.xcscheme index 7508e1e..9e308c9 100644 --- a/BrewServicesMenubar.xcodeproj/xcuserdata/andrew.xcuserdatad/xcschemes/BrewServicesMenubar.xcscheme +++ b/BrewServicesMenubar.xcodeproj/xcuserdata/andrew.xcuserdatad/xcschemes/BrewServicesMenubar.xcscheme @@ -42,7 +42,7 @@ [Service] { let task = NSTask() let outpipe = NSPipe() @@ -79,45 +131,17 @@ class AppDelegate: NSObject, NSApplicationDelegate { return [] } - func controlService(name:String, state:String) { - let task = NSTask() - let outpipe = NSPipe() - task.standardOutput = outpipe - - task.launchPath = "/usr/local/bin/brew" - task.arguments = ["services", state, name] - task.launch() - } - + let matcher = "([^ ]+)([^ ]+)" + func parseServiceList(raw: String) -> [Service] { - let r = "([^ ]+)([^ ]+)" - var services = [Service]() let rawServices = raw.componentsSeparatedByString("\n") - for s in rawServices { - let parts = matchesForRegexInText(r, text: s) - let service = Service(name: parts[0], state: parts[1]) - services.append(service) - } - return services + return rawServices[1.. Service { + let parts = matchesForRegexInText(matcher, text: raw) + let service = Service(name: parts[0], state: parts[1]) + return service; } }