You Got A Question? Ask    GNOME Community!

How To Extract Shell From GResource

In GNOME 3.12, Shell turn out to a single binary mostly for performance reasons and we lost the ability to have access to Javascript files and hacking them. By the way the same technique (GResource) has been used also in some GJS Apps.  

Why should we hack Shell at first place? That is useful in order to write an extension. There are 2 kinds of extensions.

A. Adding  something new, for example a menu that shows the applications

B. Changing a current Shell behavior, for example the “Always new instance” in Dash

Or a combination of the above two

In any case there isn’t an Extension API and what we basically do is to overriding Shell functions with our own. Maybe this technique doesn’t sound so nice and we cannot have automated tests, we cannot have a stable ABI and we can’t guarantee security or stability since extensions will always run unrestricted in the same context as Shell; but it is a powerful method since an extension is capable to achieve whatever Shell is capable of.

Extracting Shell

The docs can be found on Matthias Clasen’s post or at GNOME Wiki which I uploaded yesterday, because it is really cool practice if you don’t want to make a JHBuild installation.

1. Create a folder to store Shell Javascript files

 mkdir ~/myShell

2. Write a script to extract all necessary files

 gedit ~/getShell
    #! /bin/sh
    cd $HOME/myShell
    mkdir -p ui/components ui/status misc perf extensionPrefs gdm
    for r in `gresource list $gs`; do
     gresource extract $gs $r > ${r/#\/org\/gnome\/shell/.}

3. Make the script executable

 chmod +x ~/getShell

and run it


This will extract all the files under ~/myShell

To use this installation

 GNOME_SHELL_JS=~/myShell gnome-shell --replace
[caption id="attachment_27164" align="aligncenter" width="640"]calendar-shell Modifying Shell date menu to open Google Calendar in Chrome[/caption]

I wrote this so I can use it as reference to show you (in another post) how you can create your own extensions and change simple things that you don’t like in Shell.

  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