82 lines
1.6 KiB
Lua
82 lines
1.6 KiB
Lua
local LayoutManager = {}
|
|
|
|
-- screen.layouts, awful.layouts, and tag.layouts are all ignored.
|
|
-- This module replaces the standard layout functions.
|
|
|
|
|
|
|
|
|
|
-- Get group from layout
|
|
-- We assume that this layout is in conf.layouts
|
|
function LayoutManager:get_group(layout)
|
|
for k, v in pairs(conf.layouts) do
|
|
for l, m in pairs(v) do
|
|
if (layout == m) then
|
|
return k
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function LayoutManager:get_alt(layout)
|
|
for k, v in pairs(conf.layouts) do
|
|
for l, m in pairs(v) do
|
|
if (layout == m) then
|
|
return l
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
function LayoutManager:default_layout()
|
|
return conf.layouts[1][1]
|
|
end
|
|
|
|
-- Change layout group
|
|
function LayoutManager:group(step)
|
|
local s = awful.screen.focused()
|
|
local tag = s.selected_tag -- Multiple selected tags are NOT supported!
|
|
local layout = tag.layout
|
|
|
|
-- Subtract 1, 'cuz lua doesn't start at 0
|
|
local group = self:get_group(layout) - 1
|
|
|
|
|
|
group = ((group + step) % #conf.layouts) + 1
|
|
|
|
awful.layout.set(conf.layouts[group][1], tag)
|
|
end
|
|
|
|
-- Change layout alternate
|
|
function LayoutManager:alt(step)
|
|
local s = awful.screen.focused()
|
|
local tag = s.selected_tag -- Multiple selected tags are NOT supported!
|
|
local layout = tag.layout
|
|
|
|
-- Subtract 1, 'cuz lua doesn't start at 0
|
|
local alt = self:get_alt(layout) - 1
|
|
local group = self:get_group(layout)
|
|
|
|
|
|
alt = ((alt + step) % #conf.layouts[group]) + 1
|
|
|
|
awful.layout.set(conf.layouts[group][alt], tag)
|
|
end
|
|
|
|
function LayoutManager:next()
|
|
self:group(1)
|
|
end
|
|
function LayoutManager:prev()
|
|
self:group(-1)
|
|
end
|
|
function LayoutManager:next_alt()
|
|
self:alt(1)
|
|
end
|
|
function LayoutManager:prev_alt()
|
|
self:alt(-1)
|
|
end
|
|
|
|
return LayoutManager
|