Sam*_*her 3 javascript linux shell gnome gnome-shell-extensions
我正在编写一个简单的扩展程序,通过单击扩展程序按钮来打开浏览器。我想知道是否有一个函数可以执行传递的shell命令作为参数。另外,如果有人可以为扩展开发提供一个很好的简单参考,那将真的很有帮助。
从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);
}
}
Run Code Online (Sandbox Code Playgroud)
那里的方法有一些变化。为自己省去许多麻烦,只需为GitHub存储库添加书签。
一些快速链接:
我无法承受太多的压力,您将从阅读gnome-shell源码中学到什么。不幸的是,现在它已被编译到资源文件中,因此我们没有本地副本可以使用。