54 lines
1.4 KiB
Lua
54 lines
1.4 KiB
Lua
---------------------------------------------------------------------------
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
-- @copyright 2008 Julien Danjou
|
|
-- @release @AWESOME_VERSION@
|
|
---------------------------------------------------------------------------
|
|
|
|
-- Grab environment we need
|
|
local ipairs = ipairs
|
|
local tag = require("awful.tag")
|
|
|
|
--- Layout module for awful
|
|
module("awful.layout")
|
|
|
|
--- Get the current layout name.
|
|
-- @param screen The screen number.
|
|
function get(screen)
|
|
local t = tag.selected(screen)
|
|
if t then
|
|
return t.layout
|
|
end
|
|
end
|
|
|
|
--- Change the layout of the current tag.
|
|
-- @param layouts A table of layouts.
|
|
-- @param i Relative index.
|
|
function inc(layouts, i)
|
|
local t = tag.selected()
|
|
local number_of_layouts = 0
|
|
local rev_layouts = {}
|
|
for i, v in ipairs(layouts) do
|
|
rev_layouts[v] = i
|
|
number_of_layouts = number_of_layouts + 1
|
|
end
|
|
if t then
|
|
local cur_layout = get()
|
|
local new_layout_index = (rev_layouts[cur_layout] + i) % number_of_layouts
|
|
if new_layout_index == 0 then
|
|
new_layout_index = number_of_layouts
|
|
end
|
|
t.layout = layouts[new_layout_index]
|
|
end
|
|
end
|
|
|
|
--- Set the layout of the current tag by name.
|
|
-- @param layout Layout name.
|
|
function set(layout)
|
|
local t = tag.selected()
|
|
if t then
|
|
t.layout = layout
|
|
end
|
|
end
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|