Brian, Uli, thank you for rapid and thorough responses

I do not have a general answer, though I found a solution to my specific
problem.

What I wanted was to spawn one urxvt on each screen on startup, as desktop
backgrounds:

desktop_terminals = {}
function is_desktop_terminal(c)
  if #desktop_terminals < screen.count()
      and c.class ~= "URxvt" then
    awful.client.movetoscreen(c, #desktop_terminals + 1)
    -- setting properties
    table.insert(desktop_terminals, c)
    return true
  end
  return false
end
client.connect_signal("manage", function(c, startup)
   if is_desktop_terminal(c) then return end
   -- default code
end
for s=1,screen.count() do
  awful.util.spawn(terminal)
end

I guess you could do something like this in the generic case, or, well, at
least where the -name option is supported: (freehand&untested, for
illustration only)

function spawn_on_screen(cmd, scr)
  awful.util.spawn(cmd.." -name spawn_on_screen_".scr)
end
client.connect_signal("manage", function(c)
  scr, subs = c.class:gsub('^spawn_on_screen_','')
  if subs > 0 then
    awful.client.movetoscreen(c, tonumber(scr))
  end
end)

But that's more a hack than a proper solution

Regards,
Ole Johan Væringstad

On Thu, Mar 21, 2013 at 3:09 PM, Uli Schlachter <[email protected]> wrote:

> Hi,
>
> On 21.03.2013 05:22, Ole Johan Væringstad wrote:
> [...]
> > My question is "How do I launch/spawn a program on a given display on
> > xinerama"
>
> That's a good question. Once you figured it out, please tell me. The
> problem is
> that the window manager has no "good" way to find a connection between "I
> started some program" and "a new window appears". After all, the window
> could
> belong to something different and it just has some bad timing.
>
> There are some solution attempts:
>
> - Identify the new window via the PID. We know the PID of the process we
> started
>   and we can figure out the PID that a window belongs to. However, this
> breaks
>   as soon as some shell script is involved. The new window will be running
> under
>   a different PID.
> - The startup-notification specification tries to solve this exact problem.
>   However, AFAIK this is not supported widely (although the bare minimum of
>   this is supported in awesome!).
>
> However, none of this provides an easy way for "hey, start this on screen
> 2". At
> least I couldn't find anything from a quick look through the wiki.
>
> > I put in my rc.lua:
> > for s = 1, screen.count() do
> >   awful.util.spawn("urxvt", false, s)
> > end
> >
> > Whereupon three urxvt instances are launched on my *left* display.
>
> The screen argument is meant for non-xinerama systems were windows cannot
> be
> moved between screens. It just influences the $DISPLAY environment
> variable for
> the started process. In 3.5, it doesn't have any effect at all...
>
> > I changed it to:
> >
> > for s = 1, screen.count() do
> >   awful.screen.focus(s)
> >   awful.util.spawn("urxvt", false, s)
> > end
> >
> > Whereupon three urxvt instances are lanched on my *right* display.
> > Now I'm confused.
>
> urxvt needs some time to start. By the time its windows start to appear,
> the
> mouse is on the last monitor and thus some of the
> default-hidden-somewhere-in-awful code places this client on the last
> screen.
>
> > If I try 'awful.util.spawn("urxvt", false, n)' in the lua prompt, the
> > window is launched on my *currently focused* display, as long as n is
> > within range
> > of my screen count. If it is outside, awesome complains to stderr, as
> > expected.
>
> Again, the new client just appears wherever the mouse happens to be. :-)
>
> [...]
>
> Cheers,
> Uli
> --
> "In the beginning the Universe was created. This has made a lot of
>  people very angry and has been widely regarded as a bad move."
>
> --
> To unsubscribe, send mail to [email protected].
>

Reply via email to