GNOME JavaScript (GJS) bindings for GLib, Gtk4, cairo, clutter,

Hello folks,

To create a gnome-shell extension I’ve started writing purescript-gjs bindings for the GNOME JavaScript. The GJS conveniently exports many libraries and it can be used without the GNOME desktop environment.

I wrote enough ffi to implement simple programs using Gtk4, Clutter and a DBus client. Perhaps the bindings could be generated using the gobject-introspection (GIR) files, but I’m not entirely sure how to handle object inheritance and type convertions.

Anyway, it seems like PureScript is working really well for GJS. Please let me know if you are interested, I’d be happy to add you to the project.

Cheers,
-Tristan

13 Likes

Finally! I’ve been waiting for someone to do this, and you seem like a person who’s capable of doing it well.

2 Likes

Thank you for the kind words. Well I’m still learning the API, and reaching a decent coverage is probably a lot of work. My plan is to add bindings for the basic use cases, for example for iostream, subprocess and signal. Then once enough demo examples are working, I think we should consider a code generator, similar to what has been done with haskell-gi.

This is quite an interesting project, and it could use some help :slight_smile:

3 Likes

The project is still alive and I maintain a bunch of gnome-shell extensions with it, for example: cgroup-monitor.

To support gnome-45 (see Port Extensions to GNOME Shell 45 | GNOME JavaScript) I had to switch to the new spago in order to pass the right settings to the bundler for the new import syntax. Other than that, the bindings are rather stable and nothing else broke, which is quite amazing :slight_smile:

Cheers!

3 Likes

Is there a way to write apps with GitHub - purescript-gjs/purescript-gnome-shell: PureScript bindings for writting gnome-shell extension using The Elm Architecture?

I guess that should be possible. With gjs you can write standard gtk application, and implementing something like App.Simple - gi-gtk-declarative might be possible.

Then for gnome extension, you need to use something called Clutter and St, which provides a fairly similar API. Here is my latest one which demonstrates timer based update and a dynamic popup menu: GnomeOrgNextSchedule.purs (but not implemented with The Elm Architecture). Though beware, some functionalities are exposed without a clean API from js/ui · main · GNOME / gnome-shell · GitLab

1 Like

Interestingly enough, gjs works with gtk broadway, so you can serve gtk app using HTML5 and websocket too!

1 Like