Mack is a Golang wrapper for AppleScript. With Mack, you can easily trigger OS X desktop notifications and system sounds from within your Go application.
Mack requires OS X.
go get github.com/andybrewer/mack
Mack is ideal for local workflow optimization, OS X binary applications, or just spicing things up. For example:
When executing a long-running process, trigger a notification so you can get back to development without having to check the execution status.
package main
import"github.com/andybrewer/mack"funcmain() {
mack.Say("Starting process")
// do stuffmack.Notify("Complete")
}Interact with any Mac application from your code, like opening a URL to a HowTo video.
package main
import (
"github.com/andybrewer/mack"
)
funcmain() {
browsers:= []string{"Some new browser", "Google Chrome", "Firefox", "Safari"}
opened:=falsefor_, browser:=rangebrowsers {
_, err:=mack.Tell(browser, `open location "http://youtube.com/my-howto-video"`)
iferr!=nil {
// handle error
} else {
// exit when we found a browser that worksopened=truebreak
}
}
if!opened {
// alert user that a common browser could not be found
}
}Add a cheap GUI to your applications
package main
import"github.com/andybrewer/mack"funcmain() {
response, err:=mack.Dialog("Enter a ToDo", "ToDo Wizard", "My new ToDo")
iferr!=nil {
panic(err)
}
ifresponse.Clicked=="Cancel" {
// handle the Cancel event
} else {
newToDo:=response.Text// add ToDo to the databasemack.Notify("Added "+newToDo+" to your calendar")
}
}Manipulate the clipboard
package main
import (
"fmt""github.com/andybrewer/mack"
)
funcmain() {
// Output the content of the clipboardcontent, _:=mack.Clipboard()
fmt.Println(content)
// Change the content of the clipboardmack.SetClipboard("Hello World!")
content, _=mack.Clipboard()
fmt.Println(content)
}Currently, Mack supports the following AppleScript commands:
- Beep
- Clipboard
- Display Alert
- Display Dialog
- Display Notification
- Say
- Tell
Full documentation is available at: godoc.org/github.com/andybrewer/mack
- Andy Brewer (andybrewer)
- Hiroaki Nakamura (hnakamur)
- Antoine Augusti (AntoineAugusti)
- Gareth Watts (gwatts)
MIT