Hi,

On 02.04.2014 23:08, Manuel Kasser wrote:
I want to create/spawn a new client (a new urxvt) and hold it/catch it
in a variable to do some stuff with it afterwards.

The way I am doing this now is by spawning, catching the pid and then
find the client with this pid:

    clpid = awful.util.spawn('urxvt')
    wait(1) -- waits 1 second
    for c in awful.client.iterate(function(c) return
awful.rules.match(c, { pid = clpid }) end) do
        persistent_c = c
    end

Is it possible to spawn and catch a client in one step (or at least not
bringing out the artillery by spawning a client, throwing it away and
then get it back from the bunch of clients)?

You aren't spawning a client and throwing it away. You are spawning a *process*. That process later happens to open a new window and thus we get a client, but not all processes open one window.

Something like the following, untested code might make it easier to find the new process (beware, memleak for everything which doesn't support StartupNotification. Luckily urxvt seems to support it, needs awesome 3.5.3 or better):

-- Only needed once:
awesome.register_xproperty("_NET_STARTUP_ID", "string")

local clpid, startup_id = awful.util.spawn('urxvt', true)
client.connect_signal("manage", function(c)
  if c:get_xproperty("_NET_STARTUP_ID") == startup_id then
    persistent_c = c
  end
end)

Why is this better than just finding the new urxvt by pid in the manage hook? Dunno. It just gets more browny points for using some fancy API...

Uli

--
To unsubscribe, send mail to [email protected].

Reply via email to