如何从gnome shell扩展中调出命令行程序? [英] How do I call out to a command-line program from a gnome shell extension?

查看:94
本文介绍了如何从gnome shell扩展中调出命令行程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个简单的Shell脚本来完成一项常见任务,并且我希望能够在单击按钮时立即运行它.我已经使用gnome-shell-extension-tool创建了Hello World示例,但是现在我需要知道如何在单击时简单地使其运行任意命令.没有要考虑的输入或输出;它只需要运行.

I have written a simple shell script to accomplish a common task, and I want to be able to run it whenever a button is clicked. I've used gnome-shell-extension-tool to create the Hello World example already, but now I need to know how to simply have it run an arbitrary command when clicked. There is no input or output to be concerned with; it just needs to run.

推荐答案

经过更多创造性的搜索之后,我找到了解决方法:

After some more creative googling, I've found the solution:

const Util = imports.misc.util;
Util.spawn(['/path/to/program', 'arg1', 'arg2'])

这篇关于如何从gnome shell扩展中调出命令行程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆