You Got A Question? Ask    GNOME Community!

YES! Gnome JS Bindings Documentation is now available!

This post was made with an older stylesheet

GJS is a part of the amazing Gnome3 technologies and an excellent choice for the thousands web-developers to build small (or larger) Gnome Apps.

I’ll quickly tell you a story of mine. About a year ago I was trying to build a Gnome App to manage my Ruby on Rails instances; basically it was a user interface for RVM (Ruby’s Version Manager). Because I didn’t want to learn a new language like Vala, I was looking for JavaScript. I knew there was GJS, but I couldn’t find any documentation for it to start; and I end up to use Seed which is also a framework for Javascript bindings in Gnome.

In Seed there was a start up guide I used, but then I had to check on Python’s documentation about GTK as Seed hadn’t any GTK API docs. My torment didn’t stop there, as I was forced to ask Seed devs some things in order to complete my App.

Finally it took me 2-3 days to find out the documentation and 2-3 hours to write the App. And still with Seed you couldn’t do much because you had to check on headers file for functions as GTK bindings were way incomplete. Anyway enough said!

GJS Hello World

This is a simple example how to create a Gnome Box, but creating a webkit Gnome web-browser is like 20 more lines of code :)

//The previous line is a hash bang which tells how to run the script.
// Note that the script has to be executable (run in terminal in the right folder: chmod +x scriptname)
// Initialize GTK+
var Gtk =;
Gtk.init(null, 0);
// Create your window, name it, and connect the “click x to quit” function.
// The word “window” is a JavaScript keyword, so we have to
// call it something different.
var mywindow = new Gtk.Window({type: Gtk.WindowType.TOPLEVEL});
mywindow.title = “Hello World!”;
mywindow.connect(“destroy”, function(){Gtk.main_quit()});
// Add some text to your window
var label = new Gtk.Label({label: “Hello World”});
// Make the label and the window itself visible to the user;;
// Let the user run the app

The result

You realize how cool GJS is?  A whole new promising prospect for Gnome Apps is ahead. Besides half people in world know JS and the rest are learning :)

You better read more at Taryn’s weird(!) blog and you can also check the Gnome Javascript beginning tutorials.

  We can't watch comments unless G+ provides an API or if you send a notification, e.g +World Of Gnome
     Sometimes is better to place your questions on GNOME Community
  • Brian Robles

    Mmm.. Very nice! I remember developing Gnome Shell extensions and the lack documentation was very frustrating. This seems tangent to extension development, and it looks really promising for that and for everyday apps.

    By the way, there are a few errors in your Hello World code..
    There should be a ‘var Gtk = imports. gi.Gtk;’ right after the hash bang.
    And also, the website is forcing the quotes to be weird, so copy-pasting the code creates a parsing error. Maybe there’s a way to fix that..

    Anyway, here’s a pastebinit showing what I mean. Cheers! :)

    • Alexis Diavatis

      Jesus you debugged it? I show the error but after I had posted it. And I thought, oh well none will run it, is just for a demonstration. You rock!

    • Alexis Diavatis

      Fixed btw, thanks!

  • Alexandros Mittos

    You had me on the word “documentation”… Didn’t have to read the rest. Just kidding, of course I read it! xD

  • Liam

    I really hope to see more apps written in gjs.
    I’ll be curious to see if there are any mentions of st.