On 03.04.2014 17:40, Manuel Kasser wrote:
> Am 03.04.2014 07:50, schrieb Uli Schlachter:
[...]
>> [awesome awesome-code]
>> 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...
> I assume this set xproperty persists as long as the X-Server is up and
> running (aka over restarts of awesome)? That would solve another issue,
> tracking this urxvt over restarts of awesome (shall be spawned once, but
> not again when I restart awesome as it still fullfills its purpose).
The xproperty survives. However, the string is randomly-generated and gets
returned from awful.util.spawn(), so you cannot set it and thus...
> If so, the xproperty-String can be chosen as I see it fit, right?
Nope.
However, how about this:
-- Only needed once:
awesome.register_xproperty("_NET_STARTUP_ID", "string")
awesome.register_xproperty("AWESOME_IMPORTANT_URXVT_STARTUP_ID", "string")
function find_or_start_urxvt()
-- First try to find it
local startup_id = awesome.get_xproperty("AWESOME_IMPORTANT_URXVT_STARTUP_ID")
if startup_id ~= "" then
local c = awful.util.table.iterate(client.get(), function(c)
return c.startup_id == startup_id
end)
if c then
return c
end
-- Add a return here if you don't want to start a new instance if one was
-- already started
end
-- Couldn't find it (doesn't run yet, still starting up or exited), start it
local clpid, startup_id = awful.util.spawn('urxvt', true)
awesome.set_xproperty("AWESOME_IMPORTANT_URXVT_STARTUP_ID", startup_id)
return nil
end)
This one should survive restarts because it saves the startup id of the
interesting urxvt instance in a property on the root window.
Uli
--
- He made himself, me nothing, you nothing out of the dust
- Er machte sich mir nichts, dir nichts aus dem Staub
--
To unsubscribe, send mail to [email protected].