On 27.04.2013 16:50, Daniel wrote:
> On 2013-04-25, Uli Schlachter <[email protected]> wrote:
>> P.S.: You don't need wmctrl to find a window by pid:
>>
>> function find_by_pid(pid)
>> for _, c in pairs(client.get()) do
>> if c.pid == pid then return c end
>> end
>> end
>
> Here I attempt to first spawn and then catch the window by pid, but I
> seem to lock the spawning here? The xclock window, along with "timedout"
> pops up only after 5 seconds has passed.
>
> pid = awful.util.spawn("xclock")
> begin = os.time()
> found = false
> while not found and os.difftime(os.time(), begin) < 5 do
> for i, c in pairs(client.get()) do
> if c.pid == pid then
> wmnotify("hola")
> found = true
> break
> end
> end
> end
> if not found then
> wmnotify("timedout")
> end
Yeah, correct, you lock up awesome with this code. It doesn't process new events
from the X11 server while lua code is running.
I guess you want something like this instead (untested):
local pid = awful.util.spawn("xclock")
local callback = function(c)
if c.pid ~= pid then return end
client.disconnect_signal("manage", callback)
wmnotify("hola")
end
client.connect_signal("manage", callback)
(However, this code doesn't handle any timeouts...)
Cheers,
Uli
--
Bitte nicht mit dem verbleibenden Auge in den Laser gucken.
- Vincent Ebert
--
To unsubscribe, send mail to [email protected].