Add a custom text to GNOME panel

Simple Gnome extension may be worth to try. (I'm not sure about naming, in Ubuntu 14.04: Gnome classic uses same Gnome shell extensions, Where old classic renamed to Gnome Fallback)


Gnome Classic & Mate

  1. Download panel-applet-generator
  2. Generate a new applet:

    python panel-applet-generator.py -n mylabel -d "my custom label"
    
  3. Modify mylabelApplet.py

    try:
        from gi.repository import Gtk
    except: # Can't use ImportError, as gi.repository isn't quite that nice...
        import gtk as Gtk
    
    def applet_factory(applet, iid, data = None):
        button = Gtk.Button("It works!")
        label = Gtk.Label("It works!")
        applet.add(label)
        applet.show_all()
        return True
    

    I added label = Gtk.Label("It works!") and modified applet.add(label) (It was applet.add(button))

  4. Compress mylabel folder as tar.gz then rename it to mylabel_1.0.orig.tar.gz

  5. Build Debian package

    cd mylabel/
    debuild -us -uc
    
  6. Install package

    sudo dpkg -i ../*.deb
    
  7. Alt+Right Click or Super+Alt+Right Click on panel, then add to panel

  8. Look for mylabel applet, then add

enter image description here

References:

  • Making panel applets for Gnome 2 and 3
  • IntroDebianPackaging

Note:

  • If for any reason unable to install, It is possible to do it manually:

    sudo cp org.gnome.applets.mylabel.panel-applet /usr/share/gnome-panel/4.0/applets/
    sudo cp org.gnome.panel.applet.mylabel.service /usr/share/dbus-1/services/
    sudo cp *.py /usr/lib/gnome-applets/
    

    32bit system:

    sudo cp mylabel.server /usr/lib/bonobo/servers/ 
    

    64bit system:

    sudo cp mylabel.server /usr/lib/x86_64-linux-gnu/bonobo/servers/
    

Gnome Shell

I have tested it with Gnome 3.10:

  1. Install Gnome tweak tool

    sudo apt-get install gnome-tweak-tool
    
  2. Create new extension:

    gnome-shell-extension-tool --create-extension
    
  3. Enter requested info: name My Label, description Extension shows my custom text, uuid mylabel@yourname or leave as default mylabel@hostname

    Extension created in /home/username/.local/share/gnome-shell/extensions/mylabel@hostname

  4. extension.js is auto opened. Replace Icon with your custom label. As below:

    function init() {
        button = new St.Bin({ style_class: 'panel-button',
                              reactive: true,
                              can_focus: true,
                              x_fill: true,
                              y_fill: false,
                              track_hover: true });
        let icon = new St.Icon({ icon_name: 'system-run-symbolic',
                                 style_class: 'system-status-icon' });
    
        let label = new St.Label({ text: "Hello, world!" });
        button.set_child(label);
        button.connect('button-press-event', _showHello);
    }
    

    I added let label = new St.Label({ text: "Hello, world!" }); and modified 'button.set_child(label); (It was button.set_child(icon);)

  5. Save, Restart Gnome-Shell using Alt+F2, enter r then Enter

  6. Launch Gnome Tweak Tool → Extensions → Enable My Label extension.

  7. Restart Gnome-Shell again.

    enter image description here

References:

  • Step by step tutorial to create extensions
  • St Reference Manual
  • Documentation for writing Gnome shell extensions
  • Making GNOME Shell Extensions