【问题标题】:write a cinnamon applet that spawns a command编写一个产生命令的肉桂小程序
【发布时间】:2017-11-22 07:29:37
【问题描述】:

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

经过数小时的研究和反复试验,我终于设法生成了一个命令。但我不认为它有效地工作。许多页面返回 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);

这似乎有效......

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

有参考手册吗?最好的搜索词组是什么(在谷歌等)?

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

【问题讨论】:

    标签: javascript applet command output cinnamon


    【解决方案1】:

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

    但是,恕我直言,开发小程序的最佳选择是转到cinnamon-spices-applets github 存储库并搜索您正在尝试完成的示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-28
      • 1970-01-01
      • 1970-01-01
      • 2020-02-29
      • 1970-01-01
      • 2017-09-27
      • 1970-01-01
      • 2013-12-19
      相关资源
      最近更新 更多