zenity/internal/zenutil/osascripts/progress.js

30 lines
662 B
JavaScript
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-25 13:34:56 -04:00
try { Progress.totalUnitCount = $.getenv('total') } catch { }
try { Progress.description = $.getenv('description') } catch { }
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
}
}