40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
// Code generated by zenity; DO NOT EDIT.
|
|
// +build darwin
|
|
|
|
package zenutil
|
|
|
|
import "encoding/json"
|
|
import "text/template"
|
|
|
|
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(`
|
|
{{define "color" -}}
|
|
var app=Application.currentApplication()
|
|
app.includeStandardAdditions=true
|
|
app.activate()
|
|
var res=app.chooseColor({defaultColor:{{json .}}})
|
|
{"rgb("+res.map(x=>Math.round(x*255))+")"}
|
|
{{- end}}
|
|
{{define "file" -}}
|
|
var app=Application.currentApplication()
|
|
app.includeStandardAdditions=true
|
|
app.activate()
|
|
var res=app[{{json .Operation}}]({{json .Options}})
|
|
if(Array.isArray(res)){res.join({{json .Separator}})}else{res.toString()}
|
|
{{- end}}
|
|
{{define "msg" -}}
|
|
var app=Application.currentApplication()
|
|
app.includeStandardAdditions=true
|
|
app.activate()
|
|
var res=app[{{json .Operation}}]({{json .Text}},{{json .Options}})
|
|
if(res.gaveUp){ObjC.import("stdlib")
|
|
$.exit(5)}
|
|
if(res.buttonReturned==={{json .Extra}}){res}else{void 0}
|
|
{{- end}}
|
|
{{define "notify" -}}
|
|
var app=Application.currentApplication()
|
|
app.includeStandardAdditions=true
|
|
void app.displayNotification({{json .Text}},{{json .Options}})
|
|
{{- end}}`))
|