# Direct all graphical applications to particular monitor



## tonysonney (Aug 18, 2014)

Hi,

I am sure there has been a lot of forums with similar questions. But I couldn't find a direct answer for what I am trying to do. I am after a command line command/script which, once run, all subsequent applications with a graphical interface open on the configured monitor, out of the two monitors, I have. I cannot use the "DISPLAY" environment variable, as both my monitors are displayed under a single screen 0. I am sure this is somehow possible, because applications with a graphical interface start on the monitor where my "mouse pointer" is. Just not sure, how to do it from the command line or from a system where there wont be mouse.

Thank you in advance for any suggestions.

Thanks,
Tony


----------



## wblock@ (Aug 18, 2014)

When X is started, it enables graphics for all monitors attached to the video card.  I'm not aware of a way to leave one monitor in console mode.

Adjust your xorg.conf or .xinitrc so that both monitors show a different part of a larger virtual bitmap.  It might be easiest to use `xrandr --auto`.

After X is started, x11-wm/devilspie can be used to force applications to open in a specific location.


----------



## tonysonney (Aug 18, 2014)

Thank you @wblock@. I don*'*t mind graphics being enabled on both monitors (In fact that is good). What I am after is a technique to limit any further application when started, to start on particular monitor.

E.g.
System boots up.

I open a terminal. For argument's sake, it is displayed on monitor 1. Start mplayer again in monitor 1.
Move mouse on top of monitor 2. Start totem player, whose GUI is displayed on monitor 2.
Run the command/script to limit further applications to be on monitor 2.
Expected behaviour: any further applications started, starts on monitor 2
I did try, using `xrandr --auto`. But it does not stop GUI based application starting on either monitor. The technique of opening GUI application on the monitor where the mouse pointer is exactly, what I am looking for. But couldn't find out how it is done.


----------



## wblock@ (Aug 18, 2014)

There are two problems here.  The first is that the monitors must display different parts of the same big virtual bitmap.  Fix that problem first.  In an ideal world, that is what `xrandr --auto` would do.  In reality, you may have to set it up by declaring the large virtual bitmap in xorg.conf, or by giving a specific command like `xrandr --output DVI-0 --primary --mode 1920x1200 --pos 1280x0 --output DVI-1 --mode 1280x1024 --pos 0x0`.  This depends on which monitors you have and how they are located relative to each other.

The second problem is getting applications to open windows at a particular location.  x11-wm/devilspie does just that.


----------



## SirDice (Aug 19, 2014)

wblock@ said:
			
		

> The second problem is getting applications to open windows at a particular location.  x11-wm/devilspie does just that.


Unfortunately that doesn't always work. Some applications keep track of their position themselves, some rely on the Window Manager and others use some other method. I don't think there's a standard in this respect.


----------



## tonysonney (Aug 19, 2014)

I do not have the first problem. Both the monitors are working fine displaying different parts of the homescreen. I am only after a method to control where/how the applications are opened. I will go through "devilspie" to find out how it is controlled. My impression was there would be some message or command sent to X11 after which, all the subsequent GUI will be opened in the specified monitor.
I experimented with Ubuntu which did not have `devilspie` by default. All the gui applications I tried,when opened via keyboard, gets openened in the monitor where the Mouse pointer is. So somehow ubuntu tracks the mouse pointer and controls the monitor to be used by the application. Maybe ubuntu is using, same method as devilspie.


----------



## wblock@ (Aug 19, 2014)

x11-wm/devilspie detects when windows are created and can modify the window location.  I use this to force Firefox to always open on one monitor.


----------



## SirDice (Aug 19, 2014)

tonysonney said:
			
		

> I experimented with Ubuntu which did not have `devilspie` by default. All the GUI applications I tried,when opened via keyboard, gets opened in the monitor where the mouse pointer is. So somehow Ubuntu tracks the mouse pointer and controls the monitor to be used by the application. Maybe Ubuntu is using, same method as devilspie.


Ubuntu has GNOME 3 and Unity instead of Xorg. On Xorg it's left to the window manager to place windows. Unity may work a little different in this respect.


----------



## tonysonney (Aug 19, 2014)

SirDice said:
			
		

> Ubuntu has Gnome 3 and Unity instead of Xorg. On Xorg it's left to the Window manager to place windows. Unity may work a little different in this respect.


Thank you for the pointer. I did not like GNOME 3 and Unity. So I reverted it to GNOME classic.   .


----------

