Merge branch 'rules-screen' of https://github.com/psychon/awesome
This commit is contained in:
commit
bf652914dd
|
@ -102,7 +102,7 @@ end
|
|||
tags = {}
|
||||
awful.screen.connect_for_each_screen(function(s)
|
||||
-- Each screen has its own tag table.
|
||||
tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, awful.layout.layouts[1])
|
||||
tags[s] = awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
|
||||
end)
|
||||
-- }}}
|
||||
|
||||
|
@ -459,9 +459,9 @@ awful.rules.rules = {
|
|||
}
|
||||
}, properties = { floating = true }},
|
||||
|
||||
-- Set Firefox to always map on tags number 2 of screen 1.
|
||||
-- Set Firefox to always map on the tag named "2" on screen 1.
|
||||
-- { rule = { class = "Firefox" },
|
||||
-- properties = { tag = tags[1][2] } },
|
||||
-- properties = { screen = 1, tag = "2" } },
|
||||
}
|
||||
-- }}}
|
||||
|
||||
|
|
|
@ -9,10 +9,12 @@
|
|||
|
||||
-- Grab environment we need
|
||||
local client = client
|
||||
local screen = screen
|
||||
local table = table
|
||||
local type = type
|
||||
local ipairs = ipairs
|
||||
local pairs = pairs
|
||||
local atag = require("awful.tag")
|
||||
|
||||
local rules = {}
|
||||
|
||||
|
@ -35,6 +37,22 @@ If you want to put Firefox on a specific tag at startup, you can add:
|
|||
{ rule = { instance = "firefox" },
|
||||
properties = { tag = mytagobject } }
|
||||
|
||||
Alternatively, you can specify the tag by name:
|
||||
|
||||
{ rule = { instance = "firefox" },
|
||||
properties = { tag = "3" } }
|
||||
|
||||
If you want to put Thunderbird on a specific screen at startup, use:
|
||||
|
||||
{ rule = { instance = "Thunderbird" },
|
||||
properties = { screen = 1 } }
|
||||
|
||||
Assuming that your X11 server supports the RandR extension, you can also specify
|
||||
the screen by name:
|
||||
|
||||
{ rule = { instance = "Thunderbird" },
|
||||
properties = { screen = "VGA1" } }
|
||||
|
||||
If you want to put Emacs on a specific tag at startup, and immediately switch
|
||||
to that tag you can add:
|
||||
|
||||
|
@ -53,7 +71,7 @@ can add:
|
|||
Note that all "rule" entries need to match. If any of the entry does not
|
||||
match, the rule won't be applied.
|
||||
|
||||
If a client matches multiple rules, their applied in the order they are
|
||||
If a client matches multiple rules, they are applied in the order they are
|
||||
put in this global rules table. If the value of a rule is a string, then the
|
||||
match function is used to determine if the client matches the rule.
|
||||
|
||||
|
@ -76,7 +94,7 @@ To match multiple clients with an exception one can couple `rules.except` or
|
|||
|
||||
{ rule_any = { class = { "Pidgin", "Xchat" } },
|
||||
except_any = { role = { "conversation" } },
|
||||
properties = { tag = tags[1][1] }
|
||||
properties = { tag = "1" }
|
||||
}
|
||||
|
||||
{ rule = {},
|
||||
|
@ -193,30 +211,42 @@ end
|
|||
-- @tab props Properties to apply.
|
||||
-- @tab[opt] callbacks Callbacks to apply.
|
||||
function rules.execute(c, props, callbacks)
|
||||
local handle_later = { focus = true, switchtotag = true }
|
||||
local switchtotag = props.switchtotag
|
||||
|
||||
for property, value in pairs(props) do
|
||||
if property ~= "focus" and type(value) == "function" then
|
||||
value = value(c)
|
||||
end
|
||||
if property == "tag" then
|
||||
c.screen = value.screen
|
||||
c:tags({ value })
|
||||
elseif property == "switchtotag" and value and props.tag then
|
||||
props.tag:view_only()
|
||||
if property == "screen" then
|
||||
-- Support specifying screens by name ("VGA1")
|
||||
c.screen = screen[value]
|
||||
elseif property == "tag" then
|
||||
local t = value
|
||||
if type(t) == "string" then
|
||||
t = atag.find_by_name(props.screen, t)
|
||||
end
|
||||
c.screen = t.screen
|
||||
c:tags({ t })
|
||||
elseif property == "height" or property == "width" or
|
||||
property == "x" or property == "y" then
|
||||
local geo = c:geometry();
|
||||
geo[property] = value
|
||||
c:geometry(geo);
|
||||
elseif property == "focus" then
|
||||
-- This will be handled below
|
||||
(function() end)() -- I haven't found a nice way to silence luacheck here
|
||||
elseif type(c[property]) == "function" then
|
||||
c[property](c, value)
|
||||
else
|
||||
c[property] = value
|
||||
elseif not handle_later[property] then
|
||||
if type(c[property]) == "function" then
|
||||
c[property](c, value)
|
||||
else
|
||||
c[property] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Only do this after the tag has been (possibly) set
|
||||
if switchtotag and c.first_tag then
|
||||
c.first_tag:view_only()
|
||||
end
|
||||
|
||||
-- Apply all callbacks.
|
||||
if callbacks then
|
||||
for _, callback in pairs(callbacks) do
|
||||
|
|
|
@ -420,6 +420,19 @@ function tag.gettags(s)
|
|||
return s and s.tags or {}
|
||||
end
|
||||
|
||||
--- Find a tag by name
|
||||
-- @tparam[opt] screen s The screen of the tag
|
||||
-- @tparam string name The name of the tag
|
||||
-- @return The tag found, or `nil`
|
||||
function tag.find_by_name(s, name)
|
||||
local tags = s and s.tags or root.tags()
|
||||
for _, t in ipairs(tags) do
|
||||
if name == t.name then
|
||||
return t
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- The tag screen.
|
||||
--
|
||||
-- **Signal:**
|
||||
|
|
|
@ -35,7 +35,7 @@ local steps = {
|
|||
tags[awful.screen.focused()][1]:view_only()
|
||||
|
||||
runner.add_to_default_rules({ rule = { class = "XTerm" },
|
||||
properties = { tag = tags[awful.screen.focused()][2], focus = true } })
|
||||
properties = { tag = "2", focus = true } })
|
||||
|
||||
awful.spawn("xterm")
|
||||
end
|
||||
|
@ -75,7 +75,7 @@ local steps = {
|
|||
tags[awful.screen.focused()][1]:view_only()
|
||||
|
||||
runner.add_to_default_rules({ rule = { class = "XTerm" },
|
||||
properties = { tag = tags[awful.screen.focused()][2], focus = true, switchtotag = true }})
|
||||
properties = { tag = "2", focus = true, switchtotag = true }})
|
||||
|
||||
awful.spawn("xterm")
|
||||
|
||||
|
@ -97,7 +97,7 @@ local steps = {
|
|||
manage_cb_done = false
|
||||
|
||||
runner.add_to_default_rules({rule = { class = "XTerm" },
|
||||
properties = { tag = tags[awful.screen.focused()][2], focus = false }})
|
||||
properties = { tag = "2", focus = false }})
|
||||
|
||||
awful.spawn("xterm")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue