More gjs notes
Javascript and Gnome. Such an awkward and undocumented marriage. Still, though, some more notes on the basics. Shelling out:
#!/usr/bin/env gjs
'use strict'
const Gio = imports.gi.Gio
const argv = ['echo', 'hello', 'world']
const launcher = new Gio.SubprocessLauncher({
flags: Gio.SubprocessFlags.STDOUT_PIPE
})
const proc = launcher.spawnv(argv)
proc.wait_check(null)
const [ok, stdout, stderr] = proc.communicate_utf8(null, null)
print(stdout)
Sending data over stdin:
#!/usr/bin/env gjs
'use strict'
const Gio = imports.gi.Gio
const argv = ['cat']
const launcher = new Gio.SubprocessLauncher({
flags: Gio.SubprocessFlags.STDIN_PIPE | Gio.SubprocessFlags.STDOUT_PIPE
})
const proc = launcher.spawnv(argv)
const [ok, stdout, stderr] = proc.communicate_utf8("stdin data\n", null)
proc.wait_check(null)
print(stdout)