I'm writing an applet for Cinnamon GTK (Javascript).
After many hours of research and trial and error, I finally managed to spawn a command. But I don't think that it's working efficiently. Many pages return 404 and some pages talk about the food spice and some pages talk about applets with other languages...
Anyhow, what I'm saying is that documentation is scare.
Using Util
(from /usr/share/cinnamon/js/util.js
), trying:
Util.spawn_async(['/bin/bash', '-c', comm], CommandOutput);
and I can get the output with my 'CommandOutput(result)' function. Now I've got another method using:
let [res, pid, in_fd, out_fd, err_fd] = GLib.spawn_async_with_pipes(null, ["/usr/bin/command-name", "command-args"], null, GLib.SpawnFlags.SEARCH_PATH, null);
out_reader = new Gio.DataInputStream({base_stream: new Gio.UnixInputStream({fd: out_fd})});
let [out, size] = out_reader.read_line(null);
And this seems to work...
Please tell me the best way to perform string-functions on a command's output?
Is there some reference manual? What is the best search phrase (in Google, etc)?
P.S. I'd also like to write the command's output to a temp file. How can I do that?