Add 'callback' client property

This commit is contained in:
Emmanuel Lepage Vallee 2014-09-29 00:07:16 -04:00
parent c501fffbd5
commit 603ff2ae14
2 changed files with 11 additions and 2 deletions

View File

@ -273,6 +273,7 @@ Then edit this section to fit your needs.
| **no_autofocus** | Do not focus a new instance | boolean |
| **tag** | Asign to a pre-existing tag object | tag/func/array |
| **new_tag** | Do not focus a new instance | boolean or array |
| **callback** | A function returning an array or properties | function |
*Need default rc.lua modifications in the "client.connect_signal('focus')" section
@ -407,6 +408,14 @@ use `Alt+Return` to launch it as an `intrusive` client. You can add more section
to support more use case (such as `Shift+Return` to launch as `floating` as shown
above)
#### Can I alter the client properties based on runtime criterias?
Yes, everytime Tyrannical consider a client, it will call the `callback` function.
This function can return an array or properties that will have precedence over
any properties set by rules. The only limitation of this system is that the
callback function need to be synchronious. So long bash commands will cause
Awesome to block until the result is parsed.
#### What is Tyrannical license?
Tyrannical is licensed under the [2 clause BSD](http://opensource.org/licenses/BSD-2-Clause)

View File

@ -95,7 +95,7 @@ end
--Apply all properties
local function apply_properties(c,override,normal)
local props,ret = awful.util.table.join(normal,override),nil
local props,ret = awful.util.table.join(normal,override,override.callback and override.callback(c) or (normal.callback and normal.callback(c)) or {}),nil
--Set all 'c.something' properties, --TODO maybe eventually move to awful.rules.execute
for k,_ in pairs(props) do
if override[k] ~= nil then props[k] = override[k] else props[k] = normal[k] end
@ -113,11 +113,11 @@ local function apply_properties(c,override,normal)
if props.slave == true or props.master == true then
awful.client["set"..(props.slave and "slave" or "master")](c, true)
end
--Check if the client should be added to an existing tag (or tags)
if props.new_tag then
ret = c:tags({awful.tag.add(type(props.new_tag)=="table" and props.new_tag.name or c.class,type(props.new_tag)=="table" and props.new_tag or {})})
elseif props.tag then
ret = c:tags(type(props.tag) == "function" and props.tag(c) or (type(props.tag) == "table" and props.tag or { props.tag }))
--Add to the current tag if the client is intrusive, ignore exclusive
elseif props.intrusive == true or (settings.force_odd_as_intrusive and c.type ~= "normal") then
local tag = awful.tag.selected(c.screen) or awful.tag.viewonly(awful.tag.gettags(c.screen)[1]) or awful.tag.selected(c.screen)
if tag then --Can be false if there is no tags