2020-01-10 20:41:13 -05:00
|
|
|
// Code generated by zenity; DO NOT EDIT.
|
|
|
|
// +build darwin
|
|
|
|
|
2020-01-19 06:57:05 -05:00
|
|
|
package zenutil
|
2020-01-10 20:41:13 -05:00
|
|
|
|
2020-01-21 07:03:58 -05:00
|
|
|
import "encoding/json"
|
|
|
|
import "text/template"
|
2020-01-10 20:41:13 -05:00
|
|
|
|
2020-01-21 07:03:58 -05:00
|
|
|
var scripts = template.Must(template.New("").Funcs(template.FuncMap{"json": func(v interface{}) (string, error) {
|
|
|
|
b, err := json.Marshal(v)
|
|
|
|
return string(b), err
|
|
|
|
}}).Parse(`
|
2020-12-11 12:33:30 -05:00
|
|
|
{{define "color" -}}
|
|
|
|
tell application (path to frontmost application as text)
|
2020-01-21 07:03:58 -05:00
|
|
|
activate
|
2020-01-18 23:28:06 -05:00
|
|
|
{{if .Color -}}
|
2020-01-23 06:44:28 -05:00
|
|
|
set c to choose color default color { {{index .Color 0}},{{index .Color 1}},{{index .Color 2}} }
|
2020-01-21 07:03:58 -05:00
|
|
|
{{else -}}
|
|
|
|
set c to choose color
|
|
|
|
{{end}}
|
2020-01-21 11:13:45 -05:00
|
|
|
"rgb(" & (item 1 of c) div 256 & "," & (item 2 of c) div 256 & "," & (item 3 of c) div 256 & ")"
|
2020-01-21 07:03:58 -05:00
|
|
|
end tell
|
|
|
|
{{- end}}
|
2020-12-11 12:33:30 -05:00
|
|
|
{{define "file" -}}
|
|
|
|
var app = Application.currentApplication()
|
2020-01-10 20:41:13 -05:00
|
|
|
app.includeStandardAdditions = true
|
|
|
|
app.activate()
|
|
|
|
var opts = {}
|
2020-01-14 20:04:06 -05:00
|
|
|
{{if .Prompt -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.withPrompt = {{json .Prompt}}
|
2020-01-14 20:04:06 -05:00
|
|
|
{{end -}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{if .Type -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.ofType = {{json .Type}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{end -}}
|
|
|
|
{{if .Name -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.defaultName = {{json .Name}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{end -}}
|
|
|
|
{{if .Location -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.defaultLocation = {{json .Location}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{end -}}
|
2020-01-14 20:04:06 -05:00
|
|
|
{{if .Invisibles -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.invisibles = {{json .Invisibles}}
|
2020-01-14 20:04:06 -05:00
|
|
|
{{end -}}
|
|
|
|
{{if .Multiple -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.multipleSelectionsAllowed = {{json .Multiple}}
|
2020-01-14 20:04:06 -05:00
|
|
|
{{end -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
var res = app[{{json .Operation}}](opts)
|
2020-01-10 20:41:13 -05:00
|
|
|
if (Array.isArray(res)) {
|
2020-01-21 07:03:58 -05:00
|
|
|
res.join({{json .Separator}})
|
2020-01-10 20:41:13 -05:00
|
|
|
} else {
|
|
|
|
res.toString()
|
|
|
|
}
|
2020-01-21 07:03:58 -05:00
|
|
|
{{- end}}
|
2020-12-11 12:33:30 -05:00
|
|
|
{{define "msg" -}}
|
|
|
|
var app = Application.currentApplication()
|
2020-01-10 20:41:13 -05:00
|
|
|
app.includeStandardAdditions = true
|
|
|
|
app.activate()
|
|
|
|
var opts = {}
|
|
|
|
{{if .Message -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.message = {{json .Message}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{end -}}
|
|
|
|
{{if .As -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.as = {{json .As}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{end -}}
|
|
|
|
{{if .Title -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.withTitle = {{json .Title}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{end -}}
|
|
|
|
{{if .Icon -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.withIcon = {{json .Icon}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{end -}}
|
|
|
|
{{if .Buttons -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.buttons = {{json .Buttons}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{end -}}
|
2020-01-28 07:46:43 -05:00
|
|
|
{{if .Cancel -}}
|
|
|
|
opts.cancelButton = {{json .Cancel}}
|
|
|
|
{{end -}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{if .Default -}}
|
2020-01-21 07:03:58 -05:00
|
|
|
opts.defaultButton = {{json .Default}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{end -}}
|
2020-01-28 07:46:43 -05:00
|
|
|
{{if .Timeout -}}
|
|
|
|
opts.givingUpAfter = {{json .Timeout}}
|
2020-01-10 20:41:13 -05:00
|
|
|
{{end -}}
|
2020-01-28 07:46:43 -05:00
|
|
|
var res = app[{{json .Operation}}]({{json .Text}}, opts)
|
|
|
|
if (res.gaveUp) {
|
|
|
|
ObjC.import("stdlib")
|
|
|
|
$.exit(5)
|
|
|
|
}
|
|
|
|
if (res.buttonReturned === {{json .Extra}}) {
|
|
|
|
res
|
|
|
|
} else {
|
|
|
|
void 0
|
|
|
|
}
|
2020-01-26 11:04:49 -05:00
|
|
|
{{- end}}
|
2020-12-11 12:33:30 -05:00
|
|
|
{{define "notify" -}}
|
|
|
|
var app = Application.currentApplication()
|
2020-01-26 11:04:49 -05:00
|
|
|
app.includeStandardAdditions = true
|
|
|
|
app.activate()
|
|
|
|
var opts = {}
|
|
|
|
{{if .Title -}}
|
|
|
|
opts.withTitle = {{json .Title}}
|
|
|
|
{{end -}}
|
|
|
|
{{if .Subtitle -}}
|
|
|
|
opts.subtitle = {{json .Subtitle}}
|
|
|
|
{{end -}}
|
|
|
|
void app.displayNotification({{json .Text}}, opts)
|
2020-01-21 07:03:58 -05:00
|
|
|
{{- end}}`))
|