Add `tag` client property and avoid keeping volatile tags in memory
This commit is contained in:
parent
27d30c3ea3
commit
ab51c72484
10
README.md
10
README.md
|
@ -248,6 +248,7 @@ Then edit this section to fit your needs.
|
||||||
| **fallback** | Use this tag for unmatched clients | boolean |
|
| **fallback** | Use this tag for unmatched clients | boolean |
|
||||||
| **locked** | Do not add any more clients to this tag | boolean |
|
| **locked** | Do not add any more clients to this tag | boolean |
|
||||||
| **max_clients** | Maximum number of clients before creating a new tag | number or func |
|
| **max_clients** | Maximum number of clients before creating a new tag | number or func |
|
||||||
|
| **onetimer** | Once deleted, this tag cannot be created again | boolean |
|
||||||
|
|
||||||
★Takes precedence over class
|
★Takes precedence over class
|
||||||
|
|
||||||
|
@ -273,6 +274,8 @@ Then edit this section to fit your needs.
|
||||||
| **master** | Open a client as master (bigger) | boolean |
|
| **master** | Open a client as master (bigger) | boolean |
|
||||||
| **slave** | Open a client as slave (smaller) | boolean |
|
| **slave** | Open a client as slave (smaller) | boolean |
|
||||||
| **no_autofocus** | Do not focus a new instance | boolean |
|
| **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 |
|
||||||
|
|
||||||
*Need default rc.lua modifications in the "client.connect_signal('focus')" section
|
*Need default rc.lua modifications in the "client.connect_signal('focus')" section
|
||||||
|
|
||||||
|
@ -333,7 +336,7 @@ will allow the client into that tag. This function switch between `tile` and
|
||||||
`magnifier`:
|
`magnifier`:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local function five_layout(c,tag)
|
local function aero_or_magnifier(c,tag)
|
||||||
local count = #match:clients() + 1 --The client is not there yet
|
local count = #match:clients() + 1 --The client is not there yet
|
||||||
if count == 2 then
|
if count == 2 then
|
||||||
awful.layout.set(awful.layout.suit.tile,tag)
|
awful.layout.set(awful.layout.suit.tile,tag)
|
||||||
|
@ -366,6 +369,11 @@ Here are some example:
|
||||||
|
|
||||||
-- Spawn in the current tag, floating and on top
|
-- Spawn in the current tag, floating and on top
|
||||||
awful.util.spawn(terminal,{intrusive=true, floating=true, ontop=true})
|
awful.util.spawn(terminal,{intrusive=true, floating=true, ontop=true})
|
||||||
|
|
||||||
|
-- Spawn in an existing tag (assume `my_tag` exist)
|
||||||
|
-- Note that `tag` can also be an array of tags or a function returning
|
||||||
|
-- an array of tags
|
||||||
|
awful.util.spawn(terminal,{tag=my_tag})
|
||||||
```
|
```
|
||||||
|
|
||||||
For Awesome 3.5.6+, it is possible to replace the default mod4+r keybinding with
|
For Awesome 3.5.6+, it is possible to replace the default mod4+r keybinding with
|
||||||
|
|
|
@ -25,15 +25,15 @@ end)
|
||||||
|
|
||||||
capi.client.disconnect_signal("request::tag", ewmh.tag)
|
capi.client.disconnect_signal("request::tag", ewmh.tag)
|
||||||
capi.client.connect_signal("request::tag", function(c)
|
capi.client.connect_signal("request::tag", function(c)
|
||||||
if capi.awesome.startup then
|
-- if capi.awesome.startup then
|
||||||
--TODO create a tag on that screen
|
-- --TODO create a tag on that screen
|
||||||
else
|
-- else
|
||||||
--TODO block invalid requests, let Tyrannical do its job
|
-- --TODO block invalid requests, let Tyrannical do its job
|
||||||
local tags = c:tags()
|
-- local tags = c:tags()
|
||||||
if #tags == 0 then
|
-- if #tags == 0 then
|
||||||
--TODO cannot happen
|
-- --TODO cannot happen
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
9
init.lua
9
init.lua
|
@ -15,7 +15,7 @@ local signals,module,c_rules,tags_hash,settings,sn_callback,fallbacks,prop = {
|
||||||
"exclusive" , "init" , "volatile" , "focus_new" , "instances" ,
|
"exclusive" , "init" , "volatile" , "focus_new" , "instances" ,
|
||||||
"locked" , "class" , "instance" , "spawn" , "position" , "force_screen" ,
|
"locked" , "class" , "instance" , "spawn" , "position" , "force_screen" ,
|
||||||
"max_clients" , "exec_once" , "clone_on" , "clone_of" , "no_focus_stealing",
|
"max_clients" , "exec_once" , "clone_on" , "clone_of" , "no_focus_stealing",
|
||||||
"fallback" , "no_focus_stealing_out","no_focus_stealing_in"
|
"fallback" , "no_focus_stealing_out" ,"no_focus_stealing_in"
|
||||||
},{},{class={},instance={}},{},{},awful.spawn and awful.spawn.snid_buffer or {},{},awful.tag.getproperty
|
},{},{class={},instance={}},{},{},awful.spawn and awful.spawn.snid_buffer or {},{},awful.tag.getproperty
|
||||||
|
|
||||||
for _,sig in ipairs(signals) do
|
for _,sig in ipairs(signals) do
|
||||||
|
@ -115,6 +115,8 @@ local function apply_properties(c,override,normal)
|
||||||
end
|
end
|
||||||
if props.new_tag then
|
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 {})})
|
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
|
--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
|
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)
|
local tag = awful.tag.selected(c.screen) or awful.tag.viewonly(awful.tag.gettags(c.screen)[1]) or awful.tag.selected(c.screen)
|
||||||
|
@ -128,7 +130,6 @@ end
|
||||||
--Match client
|
--Match client
|
||||||
local function match_client(c, startup)
|
local function match_client(c, startup)
|
||||||
if not c then return end
|
if not c then return end
|
||||||
|
|
||||||
local startup = startup == nil and capi.awesome.startup or startup
|
local startup = startup == nil and capi.awesome.startup or startup
|
||||||
local props = c.startup_id and sn_callback[tostring(c.startup_id)] or {}
|
local props = c.startup_id and sn_callback[tostring(c.startup_id)] or {}
|
||||||
|
|
||||||
|
@ -185,7 +186,7 @@ local function match_client(c, startup)
|
||||||
end
|
end
|
||||||
--Last resort, create a new tag
|
--Last resort, create a new tag
|
||||||
c_rules.class[low_c] = c_rules.class[low_c] or {tags={},properties={}}
|
c_rules.class[low_c] = c_rules.class[low_c] or {tags={},properties={}}
|
||||||
local tmp,tag = c_rules.class[low_c],awful.tag.add(get_class(c),{name=get_class(c),volatile=true,exclusive=true,screen=(c.screen <= capi.screen.count())
|
local tmp,tag = c_rules.class[low_c],awful.tag.add(get_class(c),{name=get_class(c),onetimer=true,volatile=true,exclusive=true,screen=(c.screen <= capi.screen.count())
|
||||||
and c.screen or 1,layout=settings.default_layout or awful.layout.suit.max})
|
and c.screen or 1,layout=settings.default_layout or awful.layout.suit.max})
|
||||||
tmp.tags[#tmp.tags+1] = {name=get_class(c),instances = setmetatable({[c.screen]=tag}, { __mode = 'v' }),volatile=true,screen=c.screen,exclusive=true}
|
tmp.tags[#tmp.tags+1] = {name=get_class(c),instances = setmetatable({[c.screen]=tag}, { __mode = 'v' }),volatile=true,screen=c.screen,exclusive=true}
|
||||||
c:tags({tag})
|
c:tags({tag})
|
||||||
|
@ -197,9 +198,11 @@ capi.client.connect_signal("manage", match_client)
|
||||||
capi.client.connect_signal("untagged", function (c, t)
|
capi.client.connect_signal("untagged", function (c, t)
|
||||||
if prop(t,"volatile") == true and #t:clients() == 0 then
|
if prop(t,"volatile") == true and #t:clients() == 0 then
|
||||||
local rules = c_rules.class[string.lower(get_class(c))]
|
local rules = c_rules.class[string.lower(get_class(c))]
|
||||||
|
c_rules.class[string.lower(get_class(c))] = (prop(t,"onetimer") ~= true or c.class == nil) and rules or nil --Prevent "last resort tags" from persisting
|
||||||
for j=1,#(rules and rules.tags or {}) do
|
for j=1,#(rules and rules.tags or {}) do
|
||||||
rules.tags[j].instances[c.screen] = rules.tags[j].instances[c.screen] ~= t and rules.tags[j].instances[c.screen] or nil
|
rules.tags[j].instances[c.screen] = rules.tags[j].instances[c.screen] ~= t and rules.tags[j].instances[c.screen] or nil
|
||||||
end
|
end
|
||||||
|
awful.tag.history.restore(awful.tag.getscreen(t) or 1) --Explicitly return to the last tag
|
||||||
awful.tag.delete(t)
|
awful.tag.delete(t)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue