Archive for the ‘gnome’ Category

Turn your Java apps Gnome-Shell friendly
August 30, 2011

The Problem

When you try to add a java application as favorite into the Gnome Shell‘s lateral dock and run it you’ll end up having duplicated icons, one for the launcher and one for the running app. This happens b/c the shell uses an application based system for grouping tasks, so the idea is, if you add an application as a favorite launcher and you start it you’ll end having that launcher icon highlighted. Internally the shell matches the running process with the Exec clause of the .desktop file .
This works well except for applications running inside a VM or being interpreted b/c those will share the same running process. On that situation the shell inspects the WM_CLASS X Window property [1] and matches it with the full name of the desktop file. E.g. if your applications has the WM_CLASS set as “mySwingApp”, for this to successfully matched in the dock with its launcher, that launcher must be called mySwingApp.desktop located according XDG.

Note: for inspecting that value on any window you just need to run xprop WM_CLASS and click into the target window

Why is this happening?

Even if you are creating a swing application from scratch there is no easy way to tweak that X Window property using plain and portable APIs. Taking a look into openjdk sources, this is how them manages it

String mainClassName = null;

StackTraceElement trace[] = (new Throwable()).getStackTrace();
int bottom = trace.length - 1;
if (bottom >= 0) {
    mainClassName = trace[bottom].getClassName();
if (mainClassName == null || mainClassName.equals("")) {
    mainClassName = "AWT";
awtAppClassName = getCorrectXIDString(mainClassName);

As you may note what is used for this value is the name of the class running the Swing main loop.

Da solution

Digging around the web I founded a java agent and a pretty similar explanation on what’s going on.
So what I did was to fork that agent and improve it a little bit. What I did was to move it into a maven structure and remove its packaging as a fat-jar (I’m radically against fat-jars as you can see in my comments here).

The forked project is located in my github here:
and please take a look to the README there

A practical example

My first motivation on doing this was based on IntelliJ IDEA so I’ll paste here my environment.

  • Download the agent-1.0.jar and put it wherever you want (I put it into IntelliJ’s bin/ folder)
  • Edit the file bin/idea.vmoptions adding this line


  • Create the file ~/.local/share/applications/intellij-ultimate.desktop with the following content

    [Desktop Entry]
    Name=IntelliJ IDEA Ultimate Edition
    Comment=The Most Intelligent Java IDE
    Exec=env IDEA_CLASSPATH\=../lib/asm.jar /home/diego/bin/ideaIU-10.5/bin/

Latest notes

If you download the agent-1.0.jar into another location (or with another name) you must adjust the -javaagent: parameter.
Of course, change the path in the Exec entry to point to your own executable.

Hope this helps somebody, it took me a while to figure out the-right-things-to-do™ :)

[1]: Application Based GNOME 3


Iniciandome con clutter y gnome-games
April 26, 2009

Como proyecto personal voy a intentar migrar a Clutter el juego gnobots2 utilizando el upstream de Clutter al menos hasta que salga la primer 1.0 estable.

Comienzo haciendo clone de todo gnome-games, clutter y clutter-gtk
$ git clone
$ git clone git://
$ git clone git://

Compilo clutter y clutter-gtk.
Dentro de la carpeta gnome-games aplico el siguiente parche para que me deje funcionando clutter adentro de gnobots2 aplico estos dos pareches.

From 98601c7991dfed4b8a544133866070ffe11d7261 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Diego=20L=C3=B3pez=20Le=C3=B3n?=
Date: Sun, 26 Apr 2009 03:09:40 -0300
Subject: [PATCH] modified to use clutter 0.9

--- | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/ b/
index 968405e..3329f08 100644
--- a/
+++ b/
@@ -562,8 +562,8 @@ fi
if test "$enable_clutter" = "yes"; then
AC_MSG_CHECKING([for clutter API version])
- for API_VERSION in 0.8; do
- PKG_CHECK_EXISTS([clutter-$API_VERSION clutter-cairo-$API_VERSION],
+ for API_VERSION in 0.9; do
if test -z "$CLUTTER_API_VERSION"; then
@@ -571,13 +571,11 @@ if test "$enable_clutter" = "yes"; then




y luego

From 7517b3108fd3dce3bfb03b272c13115d0025db08 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Diego=20L=C3=B3pez=20Le=C3=B3n?=
Date: Sun, 26 Apr 2009 05:03:08 -0300
Subject: [PATCH] add clutter as dependency for gnobots2

gnobots2/ | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/gnobots2/ b/gnobots2/
index 377ad20..0924855 100644
--- a/gnobots2/
+++ b/gnobots2/
@@ -59,6 +59,12 @@ gnobots2_CFLAGS += $(GHTREAD_CFLAGS)
gnobots2_LDADD += $(GTHREAD_LIBS)

pixmapdir = $(pkgdatadir)/gnobots2/pixmaps
pixmap_DATA = gnomes.png \
yahoo.png \

Esto nos va a dar la posibilidad de habilitar clutter en el desarrollo de gnobots2.
Antes de trabajar hay que decirle a dónde buscar los .pc de clutter que acabamos de compilar. En mi caso sería:
$ export PKG_CONFIG_PATH=~/dev-new/c/clutter-upstream/dist/lib/pkgconfig:~/dev-new/c/clutter-gtk-upstream/dist/lib/pkgconfig
Ahora corremos el, con el fin que yo persigo sería:
$ ./ –prefix=`pwd`/dist –enable-games=gnobots2 –enable-clutter
$ make && make install
esto nos dejaría listo en dist/bin/gnobots2 el ejecutable y ya en el código podemos agregar nuestras amigas líneas de uso de clutter

Más info de clutter, leer este tutorial.
En la próxima espero ya postear avances concretos sobre el juego