So I'm making a Gnome Shell extension. And I want to be able to run some command. (The command is actually "synclient -m 100", but that is off topic)
So, what I have done so far is
s=GLib.spawn_async_with_pipes(null, ["synclient","-m","100"], null, GLib.SpawnFlags.SEARCH_PATH,null)
c=GLib.IOChannel.unix_new(s[3])
The first line spawns my process. It is definitely working.
s[3] is the file descriptor for the stout of the process. (It has something to do with pipes. Not really sure about the whole pipe thing.)
Anyway, my problem is that I can't seem to read anything from the output of synclient.
This is what I'm using for reference, but it seems that not all of the functions work. For example, I want to use add_watch, but that apperently doesn't work with gnome extensions.
I've tried using a bunch or read functions and specifically read_line_string, but they all have problems. For read_line_string it seems like it should all work except I can't figure out how to create a StringBuilder object to pass as an argument.
So, does anyone know how to get the output of a command?
Edit: also I'm kind of confused about which language the extensions use. I think it's javascript, but the docs I'm using seem to make me think Vala, whatever that is (I'm guessing a variation of java?).
Edit 2:
So, what I've got now is
let [res, pid, in_fd, out_fd, err_fd] =
GLib.spawn_async_with_pipes(
null, ["synclient","-m","100"], null, GLib.SpawnFlags.SEARCH_PATH, null);
out_reader = new Gio.DataInputStream({ base_stream: new Gio.UnixInputStream({fd: out_fd}) });
And to read a line:
let [out, size] = out_reader.read_line(null);
This gives me the output of the command, but it still doesn't give me any way to get some callback whenever the DataInputStream is changed. I need to be able to do something whenever there is a new line in the stream.