mether's Fedora Blog

Random thoughts, usually on Fedora

Icon hack for java applications

After hearing about Android Studio via Google I/O 2013, I have been toying around with underlying software called  IntelliJ IDEA Community Edition which is a pretty sweet free and open source (Apache v2 licensed)  IDE. IDEA was for packaged for a while in Fedora but has been retired unfortunately. Oddly no other linux distribution seems to be packaging it either. So I was trying to figure out how much work it is to revive it. Fedora git still has the old spec files and patches as part of its history. fedpkg clone intellij-idea and figure out the last useful git commit before it was retired via git log and make git point to that via git reset –hard e366b11. Clone the upstream git repo for IDEA and do a quick and dirty build and bingo!

Well… not quite.  Fixing the spec and associated patches etc  to build the latest version and follow the Fedora packaging guidelines would take a lot more work but one of the things that was bugging me was something that started out as a trivial thing yet turned to be a surprising problem.  The icon shown in alt+tab window was blurry. Looked around for a high resolution variant of the same icon and shoved it into hicolor icon theme directory and ran gtk-update-icon-cache only to realize that the GNOME Shell overview is showing a different icon from the one in alt+tab. Head over #fedora-desktop channel and talked to Matthias Clasen, adamw and Kalev and fiddled with a few different settings and still no go.

Read up on how GNOME Shell does the window matching and realize that this is a long standing problem with Java applications. Java sets the WM_CLASS based on the name of the class running the Swing main loop and there is no real Java API to reset it and since many applications can have the same classname, this confuses several desktop environments and window managers. A bug report has been open since early 2007 and I have filed one against Fedora openJDK in addition to the one on poor font rendering, hoping to see some progress on these issues.  Some folks have even developed elaborate hacks to fix the problem but atleast for GNOME Shell, all it took was to run sleep 5; xprop | grep WM_CLASS | awk ‘{print $4}’ and click on the IDEA window which reveals the class name as “jetbrains-idea”. If you rename the desktop file to match the classname (jetbrains-idea.desktop), GNOME Shell is able to pick up the right icon specified in the desktop file regardless of what the name or generic name is.  One can set the latter two to something appropriate like IntelliJ IDEA and GNOME Shell overview and alt+tab window would show that instead. Funky!

Written by mether

May 18, 2013 at 7:46 am

Posted in Uncategorized

3 Responses

Subscribe to comments with RSS.

  1. So does this mean I’ll be able to do “yum install intellij-idea” soon?🙂

    • Maybe🙂 I will blog about it if that happens

      mether

      May 18, 2013 at 8:32 am

    • Boggles the mind why Java doesn’t export the fully-qualified name instead

      Michel S.

      May 18, 2013 at 10:39 pm


Comments are closed.

%d bloggers like this: