Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start writing Gnome Shell extensions

I have found it's very hard to find documentation about Gnome Shell Extensions. I found some bits on Gnome Wiki (and it's first-level links), but it's not much:

http://live.gnome.org/GnomeShell/Extensions

The problem here is GJS and it's bindings. Absolutely no documentation, got lot's of SIGSEGVs, binding is just not ready (GLib, Gio and others). The only working one is unofficial documentation generated from GIR for Seed JavaScript implementation:

http://roojs.org/seed/gir-1.2-gtk-2.0/seed/

Where to get more examples? I want read directories, files, spawn processes, open network sockets and do other stuff.

Update: Show me how to read a file line by line in GJS. According Google this is not possible. Thanks.

like image 507
lzap Avatar asked Nov 28 '11 20:11

lzap


People also ask

How do you make Gnome Shell Extensions?

If you open the dconf-editor and browse org/gnome/shell/extensions, you can see extensions are saving some data there. To save your data in that path, you need to create schema xml file. Inside extension folder, create schemas folder. Inside that folder, create a file.

What are GNOME extensions written in?

GNOME Shell's UI and extensions are written in GJS, which is JavaScript bindings for the GNOME C APIs. This includes libraries like Gtk, GLib/Gio, Clutter, GStreamer and many others. Just like how PyGObject is Python bindings for the same libraries.

How do you customize GNOME extensions?

Hit Alt + F2, type "r", and press Enter: Manually installed extensions are also available in the Extensions section in Tweaks. You can enable and disable them and change their settings here, as well as on the GNOME Extensions site.


2 Answers

GNOME Shell uses GJS, not Seed. There are some differences among both of them, and it might explain why you are having problems.

With GOBject Introspection you can read the documentation for the original library and adapt the signature of every method/function to the language you are using.

In your particular case, for files, networking, etc. you might want to check GIO. You can check the Platform Overview to check what else is available. You also can check some examples (not extensions, though) in JavaScript.

At last but not least, very soon a website with extension will be launched.

like image 140
gpoo Avatar answered Sep 28 '22 04:09

gpoo


Well, supposedly, with Gnome3, you have a pretty uniform API across various programming languages, that is generated from the same GIR files. So you should (at least in theory) be able to retrieve all the API - I hope with documentation - from the GObject Introspection. And the other way round, you should be able to transform example code from another language into JavaScript for this API easily.

Theoretically. I avoid JavaScript where possible, developing a desktop application in JavaScript is the last I would do.

like image 32
Has QUIT--Anony-Mousse Avatar answered Sep 28 '22 05:09

Has QUIT--Anony-Mousse