Open an application on the desktop it was started on

I’m not sure if this is basic or not, but I suppose this kind of question has been answered before. The problem is I wasn’t able to figure out the correct keywords to search for. So I apologize in advance.

I want it to happen so that any application I open gets opened on the desk that was active when I ran the program. So for example I’m on desk 0 0 0 and I start Firefox there, and the I switch to desk 1 1 0 and Firefox still starts on desk 0 0 0. I know I can use startsondesk 0 0 0, but what if I don’t want the application to always start there? I just want it to open up on the desk where I was when I started it, regardless of the desk where I am when it’s ready to open the window, so it could be 0 0 0 this time and 0 1 0 some other time.

Is there some easy option for it, or does it require some scripting?

[color=#FF0000]Edited by theBlackDragon:
–> moved from Basic Questions[/color]

Well, the only thing I can think of is to launch the applition via a wrapper funciton, that sets the StartsOnDesktop style on the fly. You have the numbers for the current desktop and page on these variables: $[desk.n], $[page.nx] and $[page.ny]. You can use a function like this (untested):

DestroyFunc foo
AddToFunc foo
+ I Style *$0* StartsOnPage $[page.nx] $[page.ny]
+ I Exec $0

This only works if the program name is included into resource, class or title of the window. You then need to run the program using "foo " instead of just "Exec ". Some programs might need to add some additional styling regarding focus policy to avoid your mouse pointer flipping into the program when the window is mapped (and thus, taking you to the page where it is being opened).

Maybe there is an easier way, but I don’t know about it.

– Jesús Guerrero

No, no, no. Less of the “$0” stuff. Just $0 is fine. And note that since you’re calling Style in a function you should really have:

+ I UpdateStyles

after it.

But in your example it relies on the program name having the same name as the WM_TITLE which is almost never true. At best you can hope the program name matches the resource name which the style line will match – much better than the hideous “$0” which could match anything.

– Thomas Adam

The $0 was adding some more success chance when matching windows, I know that the method is not clean, and it is really not a good way to do so. But I could not think of any other way to achieve that.

You are also right about the UpdateStyles. I completely forgot about that.

– Jesús Guerrero

Sounds like work… I feel constipated already. Don’t know if it’s that important a feature, clogging up the whole config trying to achieve it. I’ll think about it.

But thanks for the help anyway. You guys here are just great (part of what makes FVWM the greatest, imho).

It’s a question that has been answered here about… three times already. Unfortunately, all the solutions are crap if only because you’re forced to launch your applications via FVWM – you can’t launch them at the shell directly unless you magically remembered to use FvwmCommand as a wrapper.

– Thomas Adam