gnome-shell – 在Gjs中使用Shell对象

我正在使用Gjs(Gnome JavaScript绑定)编写一个gtk应用程序
由于没有可用的文档,我正在阅读gnome-shell JavaScript的来源.
在我的应用程序中,我需要访问global.userdatadir.

我正在尝试将Shell对象添加到我的脚本中:

const Shell = imports.gi.Shell;

并使用#gjs myscript.js运行它
但是当我这样做的时候会给我一个错误的说法:

JS ERROR: !!!   Exception was: Error: Requiring Shell,version none: Typelib file for namespace 'Shell' (any version) not found
    JS ERROR: !!!     lineNumber = '0'
    JS ERROR: !!!     fileName = '"gjs_throw"'
    JS ERROR: !!!     stack = '"("Requiring Shell,version none: Typelib file for namespace 'Shell' (any version) not found")@gjs_throw:0
@manager.js:5
"'
    JS ERROR: !!!     message = '"Requiring Shell,version none: Typelib file for namespace 'Shell' (any version) not found"'
Error: Requiring Shell,version none: Typelib file for namespace 'Shell' (any version) not found

我不明白它有什么问题,它与Gnome-shell源文件完全一样.
其他对象都很好用import.gi.Gio,imports.gi.GLib,可以正常工作.

在Ubuntu 11.10 x64上工作

您不能通过gjs运行gnome-shell扩展,它们必须由gnome-shell本身加载.对于开发,这通常意味着将它们放在〜/ .local / share / gnome-shell / extensions / YOUR-EXTENSION-ID中,并重新启动shell.

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...