[英]Gnome Extensions - Run shell command
I am writing a simple extension to open browser by clicking the extension button. 我正在编写一个简单的扩展来打开浏览器,单击扩展按钮。 I would like to know if there is a function which can execute passed shell command as argument.
我想知道是否有一个函数可以执行传递的shell命令作为参数。 Also, it'd be really helpful if anyone can suggest a good simple reference for extension development.
此外,如果任何人都可以为扩展开发提出一个很好的简单参考,那将非常有用。
From https://github.com/GNOME/gnome-shell/blob/master/js/misc/util.js : 来自https://github.com/GNOME/gnome-shell/blob/master/js/misc/util.js :
// Runs @command_line in the background, handling any errors that
// occur when trying to parse or start the program.
function spawnCommandLine(command_line) {
try {
let [success, argv] = GLib.shell_parse_argv(command_line);
trySpawn(argv);
} catch (err) {
_handleSpawnError(command_line, err);
}
}
There are a few variations on that method in there. 那里的方法有一些变化。 Save yourself mountains of headaches and just bookmark the GitHub repository.
保存自己的头痛,只需将GitHub存储库添加为书签。
Some quick links: 一些快速链接:
I can't stress enough how much you'll get out of reading the gnome-shell source. 我不能强调你读取gnome-shell源代码的余量。 Unfortunately, it's compiled into a resource file now so we don't have local copies to stumble upon.
不幸的是,它现在被编译成一个资源文件,所以我们没有本地副本偶然发现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.