zenity/internal/zenutil/osascripts/progress.gojs

34 lines
633 B
Text
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}}
2022-03-26 20:05:52 -04:00
Progress.totalUnitCount = {{.Total}}
2021-04-30 14:19:14 -04:00
{{- end}}
{{- if .Description}}
2022-03-26 20:05:52 -04:00
Progress.description = {{json .Description}}
2021-04-30 14:19:14 -04:00
{{- end}}
2021-04-14 10:18:56 -04:00
2021-04-25 13:34:56 -04:00
while (true) {
2022-03-26 20:05:52 -04:00
var s
try {
s = $.readline('')
} catch (e) {
if (e.errorNumber === -128) $.exit(1)
break
}
2021-04-14 10:18:56 -04:00
2022-03-26 20:05:52 -04:00
if (s.indexOf('#') === 0) {
Progress.additionalDescription = s.slice(1)
continue
}
2021-04-14 10:18:56 -04:00
2022-03-26 20:05:52 -04:00
var i = parseInt(s)
if (i >= 0 && Progress.totalUnitCount > 0) {
Progress.completedUnitCount = i
continue
}
2021-04-25 13:34:56 -04:00
}