I have connected a LCD to my laptop. When I try to open a file in Nautilus, the target application opens in my laptop display, rather than the second display (in which nautilus window is open).
I don't want to change the default display. I want to open windows in the display I am working in. If my file manager is in laptop display, I want the apps to open in laptop display. If my file manager is in external display, I expect to open files there.
The output of xrandr
Screen 0: minimum 320 x 200, current 3286 x 1080, maximum 32767 x 32767
eDP1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 256mm x 144mm
1366x768 60.1*+
1360x768 59.8 60.0
1024x768 60.0
800x600 60.3 56.2
640x480 59.9
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 connected primary 1920x1080+1366+0 (normal left inverted right x axis y axis) 527mm x 296mm
1920x1080 60.0* 50.0 59.9
1920x1080i 60.1 50.0 60.0
1680x1050 59.9
1280x1024 75.0 60.0
1440x900 59.9
1280x960 60.0
1280x800 59.9
1152x864 75.0
1280x720 60.0 50.0 59.9
1440x576i 50.1
1024x768 75.1 70.1 60.0
1440x480i 60.1 60.1
832x624 74.6
800x600 72.2 75.0 60.3 56.2
720x576 50.0
720x480 60.0 59.9
640x480 75.0 72.8 66.7 60.0 59.9
720x400 70.1
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
The behaviour you describe (opening the window on the current screen) should be the default behaviour, On my 14.04 it is like that.
Due to minor incompatibilities with some graphics driver/GPU combinations, "peculiarities" might occur in some cases. If there is no "clean" option available (fix), you can use the workaround below.
It exists of a background script, looking for new windows to appear. In case a new window exists, the script compares the window position to the current mouse position. If both the mouse and the new window are not on the same screen, the window is moved, using the
xdotool
windowmove` command.Is a background script a bad idea?
If you do not need a background script, don't use it.
At the same time: if it adds important functionality and/or saves you time, It would be silly not to, if the script is well organized and therefore "low on fuel".
As a reference: on both my laptop and my Desktop, I constantly run at least 5 background scripts + occasionally some additional ones for testing purposes, without any notice.
What is done to save fuel:
Once per 10 seconds, the script checks for the second screen to be connected. If not, the script skips the whole window check- procedure and re- checks after 10 seconds. This means that the script only acts if a second screen is attached. Once a second screen is connected, within 10 seconds, the loop is changed to a period of 2 seconds.
e.g. the mouse position is only checked if there are new windows etc.
All together, on my system I could not notice nor measure any additional load, as a result of the script.
The script
How to use
The script needs both
wmctrl
andxdotool
. Run in a terminal:move_windows.py
Test- run the script by the command:
If all works as expected, add it to Startup Applications: Dash > Startup Applications > Add. Add the command: