Giter VIP home page Giter VIP logo

mack's Introduction

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

License

MIT

mack's People

Contributors

everdev avatar matthewjwhite avatar andybrewer avatar gwatts avatar antoineaugusti avatar hnakamur avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.