编写生成命令的肉桂小程序

write a cinnamon applet that spawns a command

我正在为 Cinnamon GTK (Javascript) 编写小程序。

经过数小时的研究和反复试验,我终于成功地生成了一个命令。但我认为它的工作效率不高。许多页面return 404和一些页面谈论食物香料,一些页面谈论其他语言的小程序...

无论如何,我的意思是文档很可怕。

使用 Util(来自 /usr/share/cinnamon/js/util.js),尝试:

Util.spawn_async(['/bin/bash', '-c', comm], CommandOutput);

我可以用我的 'CommandOutput(result)' 函数得到输出。 现在我有另一种方法使用:

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);

这似乎有效...

请告诉我对命令输出执行字符串函数的最佳方法?

有参考手册吗?什么是最好的搜索短语(在 Google 等中)?

P.S。我还想将命令的输出写入临时文件。我该怎么做?

有一些编写小程序的资源:

但是,恕我直言,开发 applet 的最佳选择是转到 cinnamon-spices-applets github 存储库并搜索您要完成的示例。