Mack
Mack — Golang wrapper for AppleScript
Install / Use
/learn @andybrewer/MackREADME
Mack
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.
Installation
Mack requires OS X.
go get github.com/andybrewer/mack
Usage
Mack is ideal for local workflow optimization, OS X binary applications, or just spicing things up. For example:
Workflow: Process notification
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"
func main() {
mack.Say("Starting process")
// do stuff
mack.Notify("Complete")
}
Workflow: Open applications
Interact with any Mac application from your code, like opening a URL to a HowTo video.
package main
import (
"github.com/andybrewer/mack"
)
func main() {
browsers := []string{"Some new browser", "Google Chrome", "Firefox", "Safari"}
opened := false
for _, browser := range browsers {
_, err := mack.Tell(browser, `open location "http://youtube.com/my-howto-video"`)
if err != nil {
// handle error
} else {
// exit when we found a browser that works
opened = true
break
}
}
if !opened {
// alert user that a common browser could not be found
}
}
App: ToDo list
Add a cheap GUI to your applications
package main
import "github.com/andybrewer/mack"
func main() {
response, err := mack.Dialog("Enter a ToDo", "ToDo Wizard", "My new ToDo")
if err != nil {
panic(err)
}
if response.Clicked == "Cancel" {
// handle the Cancel event
} else {
newToDo := response.Text
// add ToDo to the database
mack.Notify("Added " + newToDo + " to your calendar")
}
}
Workflow: clipboard
Manipulate the clipboard
package main
import (
"fmt"
"github.com/andybrewer/mack"
)
func main() {
// Output the content of the clipboard
content, _ := mack.Clipboard()
fmt.Println(content)
// Change the content of the clipboard
mack.SetClipboard("Hello World!")
content, _ = mack.Clipboard()
fmt.Println(content)
}
Documentation
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
Links
Contributors
- Andy Brewer (andybrewer)
- Hiroaki Nakamura (hnakamur)
- Antoine Augusti (AntoineAugusti)
- Gareth Watts (gwatts)
License
MIT
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
