PDA

View Full Version : [ubuntu] [SOLVED] How to choose which display (on dual monitor) when starting a program



Paddy Landau
July 18th, 2008, 11:10 AM
I have two screens (dual monitor).

Generally, X11 chooses on which screen to start a program, and it's quite sensible about it.

However, there are a couple of programs that I always want to start on a specific display.



Sometimes, a program specifically has an option for this. For example, firefox has a startup option --display=DISPLAY. In this case, what do I put as DISPLAY? I tried firefox --display=0 and firefox --display=VGA, but neither works ("Error: cannot open display: 0").
What about if a program doesn't have a specific option for the display? Is there a way to specify in which screen to start the program?

Paddy Landau
July 24th, 2008, 10:54 PM
Bump?

northern lights
July 24th, 2008, 11:13 PM
Edit the launcher(s) for these apps. In the box titled "Command:" enter
DISPLAY=:0 ACTUAL COMMANDwhere ACTUAL COMMAND is what is already written there.

For the other monitor, make it "DISPLAY=:1"

Paddy Landau
July 25th, 2008, 02:46 PM
Thanks for the advice.

Unfortunately, it doesn't work. I've used firefox as the test program.


From the Terminal:

"DISPLAY=:0 firefox" and "firefox --display=:0" both start firefox in the secondary monitor.
"DISPLAY=:1 firefox" and "firefox --display=:1" both return the error, "Error: cannot open display: :1".





From the menu:

"DISPLAY=:0 firefox" returns the error, "Failed to execute child process "DISPLAY=:0" (No such file or directory)".
"firefox --display=:0" opens firefox in the secondary monitor.
"DISPLAY=:1 firefox" returns the error, "Failed to execute child process "DISPLAY=:1" (No such file or directory)".
"firefox --display=:1" does nothing (presumably because of the error).



Is there, perhaps, some sort of setup I have to do first?

northern lights
July 25th, 2008, 03:00 PM
How about "DISPLAY:=0.1" instead of "...:=1"?!

Paddy Landau
July 25th, 2008, 04:17 PM
I must have something incorrectly set up.
I get an error for every one of the following.


DISPLAY=:0.1
DISPLAY=:0.2
DISPLAY=:1.0
DISPLAY=:1.1
DISPLAY=:1.2

However, the following (default value) does work, albeit on the secondary monitor.


DISPLAY=:0.0

Do you know where this is documented? I don't find it in man (presumably I'm looking in the wrong places).

unutbu
July 25th, 2008, 06:18 PM
When you have two monitors, X treats them as one display with (DISPLAY=:0.0) with a big resolution. You can control the location of some apps by using a "geometry" flag. For instance:


gnome-terminal --geometry=100x20+500+500

will open a gnome-terminal which is 100 characters wide, 20 charactors long (vertically), and which has its upper left corner set at pixel coordinate (500,500).

Firefox, on the other hand, is notoriously obstinant -- FF has no geometry flag.

There is a package, devilspie, which can give you a lot of control over where all windows appear, however. I don't use devilspie, so I can't give you specific instructions, but these might point you in the right direction:

https://help.ubuntu.com/community/Devilspie
http://burtonini.com/blog/computers/devilspie
http://foosel.org/linux/devilspie
http://ubuntuforums.org/showthread.php?t=634048

Paddy Landau
July 26th, 2008, 10:49 AM
Thanks for the information.

Devil's Pie is a fairly complex system, and I'll require a fair bit of experimentation to get it to work.

I also found a GUI interface to it from Google:
http://code.google.com/p/gdevilspie/
That's a help, too.

I've installed devilspie and gdevilspie and will slowly learn it.

Paddy Landau
July 26th, 2008, 02:47 PM
Hmm...

I've installed devilspie and gdevilspie, and experimented.

Devil's Pie works, but only on existing windows when it starts up. It doesn't work on new windows.

For example, if I start devilspie and then open Firefox, then Firefox opens in its usual place. But, if I then kill devilspie and restart it, then it moves Firefox's window to the right place.

Do you know how I fix this problem and get devilspie to work on all windows created after devilspie has started running?

(Strange name, "Devil's Pie"!)

unutbu
July 26th, 2008, 07:10 PM
Please post your devilspie script.
Not sure that I can help, but I'll see if I can get it to work on my machine...

Paddy Landau
July 27th, 2008, 01:34 PM
Please post your devilspie script.
Not sure that I can help, but I'll see if I can get it to work on my machine...
Here it is. It was automatically generated by gdevilspie. As I said, it works if I kill devilspie and restart it (on the existing windows only). The indentation is mine; the original doesn't have it.

; generated_rule Thunderbird - open email
( if
( and
( is ( application_name ) "Thunderbird" )
( matches ( window_name ) ".*- Thunderbird" )
)
( begin
( geometry "890x970+1400+0" )
( println "match" )
)
)Thanks for looking at this for me.

unutbu
July 27th, 2008, 02:15 PM
Try replacing your current script with this:


(debug)
( if
( is ( application_name ) "Thunderbird" )
( begin
( geometry "890x970+1400+0" )
)
)


If it doesn't work:
Open a terminal and type:

killall devilspie
devilspie
Open a thunderbird window to exhibit the problem.
Then post the output from devilspie.

If it does work:
Take out the (debug) line from the script and you should be good to go.

Paddy Landau
July 27th, 2008, 04:07 PM
Interesting. When I started devilspie, it gave the following output, clearly related to those windows already open.

got eof
Window Title: 'paddy@paddy-ubuntu: ~'; Application Name: 'paddy@paddy-ubuntu: ~'; Class: 'Gnome-terminal'; Geometry: 1280x800+0+224

** (devilspie:13329): CRITICAL **: e_sexp_eval: assertion `f->tree != NULL' failed
Window Title: 'Inbox - Thunderbird'; Application Name: 'Thunderbird'; Class: 'Thunderbird-bin'; Geometry: 1280x1000+1280+0

** (devilspie:13329): CRITICAL **: e_sexp_eval: assertion `f->tree != NULL' failed
Window Title: 'Desktop'; Application Name: 'File Manager'; Class: 'Nautilus'; Geometry: 2560x1024+0+0

** (devilspie:13329): CRITICAL **: e_sexp_eval: assertion `f->tree != NULL' failed
Window Title: 'Bottom Expanded Edge Panel'; Application Name: 'Bottom Expanded Edge Panel'; Class: 'Gnome-panel'; Geometry: 1280x24+1280+1000

** (devilspie:13329): CRITICAL **: e_sexp_eval: assertion `f->tree != NULL' failedThen, when I opened a new email, it gave the following extra output.

Window Title: 'Mozilla Thunderbird'; Application Name: 'Thunderbird'; Class: 'Thunderbird-bin'; Geometry: 900x800+1280+0

** (devilspie:13329): CRITICAL **: e_sexp_eval: assertion `f->tree != NULL' failedI don't know where to look up these "CRITICAL" codes; do you? I don't find any troubleshooting or error codes anywhere in the official Devil's Pie pages.

Paddy Landau
July 27th, 2008, 04:10 PM
Stop press...

It's working, despite those messages!

I'll now experiment to find out where I went wrong, and post the results once I've found out.

overdrank
July 27th, 2008, 04:17 PM
Moved to Multimedia & Video :)

Paddy Landau
July 27th, 2008, 04:29 PM
I'll now experiment to find out where I went wrong, and post the results once I've found out.
I have to thank you for pointing me in the right direction.

It seems that when Thunderbird opens a window, it opens it as one name and immediately renames it. Thus, my initial condition, which included the window name, was causing Devil's Pie to skip it.

Thanks again!

mixmastamyk
January 6th, 2011, 12:23 AM
Been wrestling with the same problem and was able to beat Thunderbird into submission like so. Doesn't need a background process either. Put this into the launcher icon:


sh -c "thunderbird %u & sleep 3; wmctrl -r thunderbird -b remove,maximized_vert,maximized_horz; wmctrl -r thunderbird -e 0,1920,0,1200,1600"

BicyclerBoy
January 6th, 2011, 05:02 AM
If you use separate x screens for each display then the DISPLAY variable works..

This is a config option for nvidia X server.

Most apps stay on the screen they are launched from etc..
Complete video mode independence etc..