gnome-shell

Use of Shell object in Gjs


I am writing a gtk+ app using Gjs ( Gnome JavaScript bindings ) As there are no documents available i am reading the sources of gnome-shell JavaScript's . In my app i need to get access to global.userdatadir .

I am trying to add the Shell object to my script :

const Shell = imports.gi.Shell;

and run it with #gjs myscript.js but when i do this it throws me an error saying :

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

I cant understand what's wrong with it , it is exactly as in Gnome-shell source files. Other objects are fine using imports.gi.Gio , imports.gi.GLib , works OK .

Working on Ubuntu 11.10 x64


Solution

  • You can't run gnome-shell extensions via gjs, they have to be loaded by gnome-shell itself. For development, this usually means putting them in ~/.local/share/gnome-shell/extensions/YOUR-EXTENSION-ID and restarting the shell.