mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-10 18:24:22 +02:00
tags: rework how tags are defined
Instead of using a list of names and a list of layouts, we use an array with optional names and layouts and additional properties. If no name is given, only numerical ID is used. Default to first layout. Additional properties are set using `setproperty`.
This commit is contained in:
parent
7901e0c294
commit
e5e338e8ee
2 changed files with 29 additions and 13 deletions
9
rc.lua
9
rc.lua
|
@ -40,6 +40,15 @@ config.layouts = {
|
||||||
awful.layout.suit.fair,
|
awful.layout.suit.fair,
|
||||||
awful.layout.suit.floating,
|
awful.layout.suit.floating,
|
||||||
}
|
}
|
||||||
|
config.tags = {
|
||||||
|
{ layout = awful.layout.suit.fair }, -- 1
|
||||||
|
{ name = "emacs", mwfact = 0.6 },
|
||||||
|
{ name = "www", mwfact = 0.7 },
|
||||||
|
{ name = "im" , mwfact = 0.2 },
|
||||||
|
{ }, -- 5
|
||||||
|
{ }, -- 6
|
||||||
|
{ }, -- 7
|
||||||
|
}
|
||||||
config.hostname = awful.util.pread('uname -n'):gsub('\n', '')
|
config.hostname = awful.util.pread('uname -n'):gsub('\n', '')
|
||||||
|
|
||||||
-- Remaining modules
|
-- Remaining modules
|
||||||
|
|
33
rc/tags.lua
33
rc/tags.lua
|
@ -2,17 +2,18 @@
|
||||||
|
|
||||||
loadrc("sharetags")
|
loadrc("sharetags")
|
||||||
|
|
||||||
local tags = { names = { 1, "emacs", "www", "im", 5, 6, 7 },
|
local otags = config.tags
|
||||||
layout = { awful.layout.suit.tile,
|
|
||||||
awful.layout.suit.tile,
|
|
||||||
awful.layout.suit.tile,
|
|
||||||
awful.layout.suit.tile,
|
|
||||||
awful.layout.suit.tile,
|
|
||||||
awful.layout.suit.tile,
|
|
||||||
awful.layout.suit.tile }}
|
|
||||||
tags = sharetags.create_tags(tags.names, tags.layout)
|
|
||||||
config.tags = {}
|
config.tags = {}
|
||||||
|
|
||||||
|
local names = {}
|
||||||
|
local layouts = {}
|
||||||
|
for i, v in ipairs(otags) do
|
||||||
|
names[i] = v.name or i
|
||||||
|
layouts[i] = v.layout or config.layouts[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
tags = sharetags.create_tags(names, layouts)
|
||||||
|
|
||||||
-- Compute the maximum number of digit we need, limited to 9
|
-- Compute the maximum number of digit we need, limited to 9
|
||||||
keynumber = math.min(9, #tags)
|
keynumber = math.min(9, #tags)
|
||||||
|
|
||||||
|
@ -20,10 +21,20 @@ keynumber = math.min(9, #tags)
|
||||||
-- Be careful: we use keycodes to make it works on any keyboard layout.
|
-- Be careful: we use keycodes to make it works on any keyboard layout.
|
||||||
-- This should map on the top row of your keyboard, usually 1 to 9.
|
-- This should map on the top row of your keyboard, usually 1 to 9.
|
||||||
for i = 1, #tags do
|
for i = 1, #tags do
|
||||||
|
-- Name
|
||||||
config.tags[tags[i].name] = tags[i]
|
config.tags[tags[i].name] = tags[i]
|
||||||
if tags[i].name ~= tostring(i) then
|
if tags[i].name ~= tostring(i) then
|
||||||
tags[i].name = tostring(i) .. "↭" .. tags[i].name
|
tags[i].name = tostring(i) .. "↭" .. tags[i].name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Properties
|
||||||
|
for pname, pvalue in pairs(otags[i]) do
|
||||||
|
if pname ~= "name" and pname ~= "layout" then
|
||||||
|
awful.tag.setproperty(tags[i], pname, pvalue)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Key bindings
|
||||||
if i <= keynumber then
|
if i <= keynumber then
|
||||||
config.keys.global = awful.util.table.join(
|
config.keys.global = awful.util.table.join(
|
||||||
config.keys.global,
|
config.keys.global,
|
||||||
|
@ -71,7 +82,3 @@ for i = 1, #tags do
|
||||||
end))
|
end))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
awful.tag.setproperty(config.tags.emacs, "mwfact", 0.6)
|
|
||||||
awful.tag.setproperty(config.tags.www, "mwfact", 0.7)
|
|
||||||
awful.tag.setproperty(config.tags.im, "mwfact", 0.2)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue