zenity/internal/zenutil/osascripts/progress.gojs

29 lines
545 B
Text
Raw Permalink Normal View History

2022-06-01 19:00:08 -04:00
{{template "common" .}}
2021-04-14 10:18:56 -04:00
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
try {
2022-05-06 08:48:31 -04:00
var s = $.readline('')
2022-03-26 20:05:52 -04:00
} 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
}
2021-04-25 13:34:56 -04:00
}