Make Intellij IDEA behave properly in linux docks
One of my pet peeves when working on Linux has always been that java applications do not work well with popular docks like Docky and Cairo dock. When you add a Java application as a launcher to the dock and use it to launch the application it will still create another icon in the dock, which in a way defeats the purpose of a dock. Reading the comments in following bugreport made it apparent to me, that this is not something that can be easily fixed by the dock’s authors, since the problem lies within the jdk. A workaround exists but it does not apply to all Java applications.
One of the applications the workaround does not work for, unfortunately is Intellij IDEA. The one application I use most on a day to day basis.
When you request the WM_CLASS for Intellij it will identify itself as java-lang-Thread
xprop | grep WM_CLASS | awk '{print $4}' "java-lang-Thread"
Which is not something that can be used to identify all windows belonging to Intellij. So I decided to see if I could work around this problem, and succeeded. Here’s what you do to make Intellij behave properly
UPDATE 23-01-2010 : whoah seems my original approach had some issues with classloading. (Who needs to create new classes anyway 😉 ) So here are the new and improved instructions.
1. Download agent.jar and copy it to Intellij’s bin folder.
I wont describe in detail what this jar does. But it’s something i created that changes the default value sun.awt.X11.XToolkit assigns to WM_CLASS. The sources are included in the jar
2. Open idea.sh And change the line that looks like
exec $IDEA_JDK/bin/java $JVM_ARGS $IDEA_MAIN_CLASS_NAME $*
to
exec $IDEA_JDK/bin/java -javaagent:agent.jar=Intellij_IDEA $JVM_ARGS $IDEA_MAIN_CLASS_NAME $*
3. Find the .desktop file that is used to start intellij by executing the following command from your home folder
find . -name '*.desktop' -exec grep -H idea.sh {} \;
4. Edit the file you found in step 3 and add the following line
StartupWMClass=Intellij_IDEA
Done!