Run on separate monitor
Hi,
I have a dual monitor setup and I would like to use Intellij IDEA so that when I start a program, it runs on a specific screen. I am using i3wm on Linux. I found out that if I launch a run configuration for a java swing program in IDEA, the WM_CLASS property of the window is set to "com-intellij-rt-execution". This allows me to set a rule in my window manager to put these windows on my "run" monitor. However, this property does not get set to an intellij-specific value if I run debug. Which means I would have to set a wm rule for all the applications I am working on, dependending on their WM_CLASS, which is not really convenient.
Is there any way I could get the behaviour I want in debug mode as well? Either by changing the WM_CLASS property in debug mode, or another (possibly "cleaner" way)?
Thanks!
Benoît.
IDEA ultimate 2016.3.5
Build #IU-163.13906.18
Please sign in to leave a comment.
This forum may be not the best place for this Linux specific question. http://unix.stackexchange.com/ might be a better place.
Not really as I know how to configure my WM to put the windows on a given monitor.
What I would need is a way to configure intellij so that the behaviour of the debug mode is the same as a normal run, e.g. the WM_CLASS property gets set to a specific value I can use. A special string in the window title could also be acceptable.
IntelliJ IDEA doesn't set it explicitly anywhere, it's some side effect that is OS specific. On Windows, window class would be always SunAwtFrame no matter how you start it, in Run or in Debug.
Reply from the developers:
WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "SomeTest"
Same way, but I get a different result:
In debug mode, I do get "SomeTest" which what I want to change.
In any case, if this is not an intended feature, is there any other way to get the desired behaviour? It doesn't seem so far out to make use of a multimonitor setup to place your code on one monitor and your application being debugged on the other, does it?
It has changed in 2017.1, instead of running AppMain launcher IntelliJ IDEA is using javaagent, hence it would be the same in Run and in Debug: https://github.com/JetBrains/intellij-community/blob/c9e05539e985de432e070200ad78594498ee6202/java/execution/impl/src/com/intellij/execution/runners/ProcessProxyFactoryImpl.java#L52-L52.
WM_CLASS would always contain the class name of your application no matter if you Run or Debug.
I am indeed on 2016.3.5. So any other way to do this then?
Create a second class with main() method, but with different name, this class will be the wrapper and will call your original main(). When running/debugging from IntelliJ IDEA, use the new wrapper class, when running from the terminal, use the original wrapper class. This way you can reposition the window by the class name when it's running from IntelliJ IDEA.
Thanks for the suggestion. I would prefer to avoid having to touch my run configurations as we check those into VCS + I work on many different projects, some with many runconfs, so it's a lot of work.
Run configurations can be Shared and local, local configurations are not shared, so it would not be a problem.
As an alternative, you can create some watchdog which will monitor the started processes and trigger reposition script based on the class name and on the name of the parent process (if the parent process is IntelliJ IDEA).
I like the idea of checking on the parent process. I think I will try something like that.
Hey, I use i3 too and I have a similar problem with binding intellij idea window.
My workflow is to create separate i3 workspaces for different projects. If I need to work on a project I just run a script that creates a new workspace, loads a project preconfigured layout, and automatically startups some applications. For every preconfigured layout I have a couple of rules that bind applications to a workspace by WM_CLASS window property value. I can bind every application to a workspace but not intellij idea because WM_CLASS has static value and WM_NAME depends on a current open project file.
So, I want to bind intellij idea window to the special workspace.
Is there a way to change intellij idea WM_CLASS window property value on startup? Can you give me advice on how to achieve this?
Hi Frolov Dmitrii,
I'm not sure if the property can be changed, but did you try using https://i3wm.org/docs/userguide.html#command_criteria?
Hi Arseniy Nisnevich,
Command criteria is a feature to apply commands to all clients with the same property (by criteria). For example, by WM_CLASS or WM_NAME property. I can create a shortcut to close only Intellij IDEA windows wherever they are without choosing them on all workspace. So this feature doesn't help me to bind windows to placements I want
Dmitrii,
Try using https://unix.stackexchange.com/questions/137150/how-to-move-a-window-to-a-different-workspace-using-its-id-in-bash
You can grep the particular project window ID through WM_NAME.