Add 3 new focus stealing policies
Globals: * tyrannical.settings.block_children_focus_stealing = true --Block popups () * tyrannical.settings.group_children = true --Force popups/dialogs to have the same tags as the parent client Tags: * no_focus_stealing --Prevent new clients from selecting the tags (good for chat windows), make the new client "urgent" instead Also update the documentation to match those additions
This commit is contained in:
parent
8943c63020
commit
926d43842c
36
README.md
36
README.md
|
@ -136,22 +136,32 @@ tyrannical.properties.ontop = {
|
|||
tyrannical.properties.centered = {
|
||||
"kcalc"
|
||||
}
|
||||
|
||||
tyrannical.settings.block_children_focus_stealing = true --Block popups ()
|
||||
tyrannical.settings.group_children = true --Force popups/dialogs to have the same tags as the parent client
|
||||
|
||||
```
|
||||
|
||||
Then edit this section to fit your needs. That available tag properties are:
|
||||
* mwfact
|
||||
* nmaster
|
||||
* ncol
|
||||
* icon
|
||||
* hide
|
||||
* screen (number or array)
|
||||
* exclusive
|
||||
* layout
|
||||
* init
|
||||
* clone_on
|
||||
* class
|
||||
* exec_once
|
||||
* selected
|
||||
|
||||
| Property | Description | Type |
|
||||
| --------------------- | ---------------------------------------------- |:----------------:|
|
||||
| **mwfact** | Tiled layout master/slave ratio | float(0-1) |
|
||||
| **nmaster** | Number of master clients | number |
|
||||
| **ncol** | Number of columns | number |
|
||||
| **icon** | Tag icon | path |
|
||||
| **hide** | Hide this tag from view | boolean |
|
||||
| **screen** | Tag screen(s) | number or array |
|
||||
| **exclusive** | Allow only client from the "class" attributes | boolean |
|
||||
| **layout** | The tag layout | layout |
|
||||
| **init** | Create when awesome launch | boolean |
|
||||
| **clone_on** | Create a clone on screen(s) | number or array |
|
||||
| **class** | Match these classes to this tag | array of string |
|
||||
| **exec_once** | Execute when the tag is first selected | string (command) |
|
||||
| **selected** | Select when created | boolean |
|
||||
| **volatile** | Destroy when the last client is closed | boolean |
|
||||
| **force_screen** | Force a screen | number |
|
||||
| **no_focus_stealing** | Prevent tag from stealing focus on new clients | boolean |
|
||||
|
||||
The available client properties are:
|
||||
* floating
|
||||
|
|
46
init.lua
46
init.lua
|
@ -7,8 +7,6 @@ local awful = require("awful")
|
|||
local capi = {client = client , tag = tag ,
|
||||
screen = screen , mouse = mouse }
|
||||
|
||||
local module = {}
|
||||
|
||||
-------------------------------INIT------------------------------
|
||||
|
||||
local signals = {
|
||||
|
@ -23,7 +21,7 @@ for _,sig in ipairs(signals) do
|
|||
end
|
||||
|
||||
-------------------------------DATA------------------------------
|
||||
local class_client,matches_client,tags_hash = {},{},{}
|
||||
local module,class_client,matches_client,tags_hash,settings = {},{},{},{},{}
|
||||
|
||||
--------------------------TYRANIC LOGIC--------------------------
|
||||
|
||||
|
@ -90,7 +88,10 @@ local function match_client(c, startup)
|
|||
if not c then return end
|
||||
local low = string.lower(c.class or "N/A")
|
||||
local rules = class_client[low]
|
||||
if rules then
|
||||
if c.transient_for and settings.group_children == true then
|
||||
c.sticky = c.transient_for.sticky or false
|
||||
return c:tags(c.transient_for:tags())
|
||||
elseif rules then
|
||||
--Force floating state if necessary
|
||||
if rules.properties.floating ~= nil then
|
||||
awful.client.floating.set(c, rules.properties.floating)
|
||||
|
@ -100,7 +101,7 @@ local function match_client(c, startup)
|
|||
awful.placement.centered(c, nil)
|
||||
end
|
||||
--Focus new client
|
||||
if rules.properties.focus_new ~= false then
|
||||
if rules.properties.focus_new ~= false and (c.transient_for and not settings.block_transient_for_focus_stealing) then
|
||||
capi.client.focus = c
|
||||
end
|
||||
--Set other properties
|
||||
|
@ -115,8 +116,7 @@ local function match_client(c, startup)
|
|||
end
|
||||
tag = awful.tag.selected(c.screen)
|
||||
if tag then --Can be false if there is no tags
|
||||
c:tags({tag})
|
||||
return
|
||||
return c:tags({tag})
|
||||
end
|
||||
end
|
||||
--TODO pre_match
|
||||
|
@ -137,8 +137,11 @@ local function match_client(c, startup)
|
|||
end
|
||||
if #tags > 0 then
|
||||
c:tags(tags)
|
||||
if awful.tag.getproperty(tags[1],"focus_new") ~= false then
|
||||
if awful.tag.getproperty(tags[1],"focus_new") ~= false and not (c.transient_for and settings.block_transient_for_focus_stealing)
|
||||
and not awful.tag.getproperty(tags[1],"no_focus_stealing") then
|
||||
awful.tag.viewonly(tags[1])
|
||||
elseif awful.tag.getproperty(tags[1],"no_focus_stealing") then
|
||||
c.urgent = true
|
||||
end
|
||||
return
|
||||
end
|
||||
|
@ -171,7 +174,6 @@ capi.client.connect_signal("untagged", function (c, t)
|
|||
end
|
||||
end)
|
||||
|
||||
-- awful.tag.withcurrent = function() end --Disable automatic tag insertion
|
||||
awful.tag.withcurrent,awful.tag._add = function(c, startup)
|
||||
local tags,old_tags = {},c:tags()
|
||||
--Safety to prevent
|
||||
|
@ -215,6 +217,8 @@ awful.tag.setscreen,awful.tag._viewonly = function(tag,screen) --Why this isn't
|
|||
end,awful.tag.viewonly
|
||||
|
||||
awful.tag.viewonly = function(t)
|
||||
if not t then return end
|
||||
if not awful.tag.getscreen(t) then awful.tag.setscreen(1) end
|
||||
awful.tag._viewonly(t)
|
||||
if awful.tag.getproperty(t,"clone_of") then
|
||||
awful.tag.swap(t,awful.tag.getproperty(t,"clone_of"))
|
||||
|
@ -231,24 +235,8 @@ awful.tag.swap = function(tag1,tag2)
|
|||
end
|
||||
|
||||
--------------------------OBJECT GEARS---------------------------
|
||||
local properties = setmetatable({}, {__newindex = function(table,k,v) load_property(k,v) end})
|
||||
local getter = {properties = setmetatable({}, {__newindex = function(table,k,v) load_property(k,v) end}),
|
||||
settings = settings, tags_by_name = tags_hash} --Getter only, use .tags for setter, see syntax
|
||||
local setter = {tags = load_tags}
|
||||
|
||||
local function getter (table, key)
|
||||
if key == "properties" then
|
||||
return properties
|
||||
elseif key == "tags_by_name" then
|
||||
return tags_hash --Getter only, use .tags for setter, see syntax
|
||||
end
|
||||
end
|
||||
local function setter (table, key,value)
|
||||
if key == "tags" then --Setter only, use "tags_by_name" to get
|
||||
load_tags(value)
|
||||
elseif key == "properties" then
|
||||
properties = value
|
||||
for k,v in pairs(tyrannical_properties) do
|
||||
load_property(k,v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return setmetatable(module, { __call = function(_, ...) return end , __index = getter, __newindex = setter})
|
||||
return setmetatable(module,{__index=function(t,k) return getter[k] end,__newindex=function(t,k,v) if setter[k] then return setter[k](v) end end})
|
||||
|
|
Loading…
Reference in New Issue