Created
June 14, 2017 05:18
-
-
Save groob/eee199c77c8aae0affff102b6c4720f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
/* | |
#cgo darwin CFLAGS: -DDARWIN -x objective-c | |
#cgo darwin LDFLAGS: -framework Cocoa | |
#import <Cocoa/Cocoa.h> | |
void DockRunning() { | |
int isRunning = 0; | |
NSWorkspace * ws = [NSWorkspace sharedWorkspace]; | |
while (isRunning == 0) { | |
NSArray *runningApps = ws.runningApplications; | |
NSPredicate *dockPredicate = [NSPredicate predicateWithFormat:@"bundleIdentifier == 'com.apple.dock'"]; | |
NSArray *dock = [runningApps filteredArrayUsingPredicate:dockPredicate]; | |
isRunning = [dock count]; | |
if (isRunning == 0) { | |
[[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]; | |
} | |
} | |
} | |
*/ | |
import "C" | |
import "fmt" | |
func main() { | |
fmt.Println("waiting for dock to launch") | |
C.DockRunning() | |
fmt.Println("done") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment