Script.qml 674 B

123456789101112131415161718192021222324252627282930
  1. import QtQuick 2.0
  2. import Process 1.0
  3. Process {
  4. id: process
  5. property string output
  6. property string scriptsPath: applicationDirPath + "/../scripts/"
  7. function exec(text) {
  8. output = ""
  9. console.log(`starting: bash -c [${text}]`)
  10. start("bash", ["-c", text])
  11. }
  12. function execScript(name, args) {
  13. let argsList = typeof args === "string" ? [args] : args || []
  14. var strArgs = ""
  15. for (let arg of argsList) {
  16. strArgs += ` '${arg.replace(/'/g, "\\\'")}'`
  17. }
  18. exec(`"${scriptsPath + name}"${strArgs}`)
  19. }
  20. onOutputRead: {
  21. process.output = process.output + output
  22. }
  23. }