zenity/internal/zenutil/osascripts/progress.gojs

34 lines
683 B
Plaintext
Raw Normal View History

2021-04-14 10:18:56 -04:00
var app = Application.currentApplication()
app.includeStandardAdditions = true
app.activate()
ObjC.import('stdlib')
ObjC.import('readline')
2021-04-30 14:19:14 -04:00
{{- if .Total}}
Progress.totalUnitCount = {{.Total}}
{{- end}}
{{- if .Description}}
Progress.description = {{json .Description}}
{{- end}}
2021-04-14 10:18:56 -04:00
2021-04-25 13:34:56 -04:00
while (true) {
var s
try {
s = $.readline('')
} catch (e) {
if (e.errorNumber === -128) $.exit(1)
break
}
2021-04-14 10:18:56 -04:00
2021-04-25 13:34:56 -04:00
if (s.indexOf('#') === 0) {
Progress.additionalDescription = s.slice(1)
continue
2021-04-14 10:18:56 -04:00
}
2021-04-25 13:34:56 -04:00
var i = parseInt(s)
if (i >= 0 && Progress.totalUnitCount > 0) {
Progress.completedUnitCount = i
continue
}
}