Fixing dash/dock icons for SQLDeveloper and IntelliJ in Gnome3 Dock/dash

With the coming demise of Ubuntu’s Unity it’s time to look at Gnome3, the supposed successor.

I’m using Dash-to-Dock, and noticed that it did not play nice with Java applications: when I start Oracle SQLDeveloper it shows a second icon for SQLDeveloper, even though the icon is already in the dock. If I start both SQLDeveloper and IntelliJ from the dock it gets worse, as IntelliJ is seen as the second “window” of SQLDeveloper 8-/

The problem is caused by a bug/oversight in the JDK (known for years and of course not fixed) where it assigns the same WM_CLASS to any Java program. WM_CLASS is used by launchers to distinguish between programs, so when all Java programs use the same WM_CLASS things go awry.

To fix this is a bit of work, so let’s delve in.

First check the window IDs of the programs you have trouble with.

Start the program you need to check, then open a terminal and enter

xprop WM_CLASS

Now use CTRL+TAB to move to the program’s main window and click it. That should show the window-ID in the terminal:

WM_CLASS(STRING) = “sun-awt-X11-XFramePeer”, “jetbrains-idea”

For Oracle SQLDeveloper this thingjust shows:

WM_CLASS(STRING) = “sun-awt-X11-XFramePeer”, “”

We need SQLDeveloper to also add a unique string at the end. Sadly enough there is no environment or command line option you can use, but we can use a trick.. A special Java Agent (thanks, jelmerk) can be used to “patch” the Java class that defines the window name at class load time. The page linked to contains a very old version of the code, but there is a push request for a Java 8 version. This results in the following jar that you need to download:

agent.jar

Now we need to fix SQLDeveloper to use this, as follows:

Now restart SQLDeveloper and again use xprop WM_CLASS to see what the window ID is now, it should answer with:

WM_CLASS(STRING) = “sun-awt-X11-XFramePeer”, “SqlDeveloper”

The second part is to teach Gnome3 to distinguish between these Java programs. For that you need to edit the .desktop files that launch these applications, usually found in your home directory under ~/.local/share/applications. My sqldeveloper.desktop file there reads:

The “SqlDeveloper” there must be the exact same string that you used when you changed the ide.conf file.

We need to do the same for IntelliJ, but we do not need the agent.jar because it already defines a WMCLASS. Just add the following to your intellij.desktop file:

StartupWMClass=jetbrains-idea

After these changes log out and log in again, after that the dash should correctly associate icons with the windows.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部