local P = {} local Widget = require("desktop.layoutmanager.widget") P.__index = P -- screen.layouts, awful.layouts, and tag.layouts are all ignored. -- This module replaces the standard layout functions. function P:new(screen) local l = { layouts = conf.layouts, screen = screen.screen } setmetatable(l, self) l._widget = Widget:new(l) l.widget = l._widget.widget return l --[[ Example conf.layouts = { { awful.layout.suit.tile.left, awful.layout.suit.tile, }, { awful.layout.suit.fair, awful.layout.suit.fair.horizontal, }, { awful.layout.suit.floating, } } --]] end -- Find layout in self.layouts -- Returns group index, alt index function P:find_layout(layout) for k, v in pairs(self.layouts) do for l, m in pairs(v) do if (layout == m) then return k, l end end end end function P:get_default_layout() return self.layouts[1][1] end -- Change layout group function P:change_group(step) local tag = self.screen.selected_tag -- Multiple selected tags are NOT supported! local layout = tag.layout -- Subtract 1, lua doesn't start at 0 local g, a g, a = self:find_layout(layout) g = g - 1 g = ((g + step) % #self.layouts) + 1 awful.layout.set(self.layouts[g][1], tag) end -- Change layout alternate function P:change_alt(step) local tag = self.screen.selected_tag -- Multiple selected tags are NOT supported! local layout = tag.layout -- Subtract 1, lua doesn't start at 0 local g, a g, a = self:find_layout(layout) a = a - 1 a = ((a + step) % #self.layouts[g]) + 1 awful.layout.set(self.layouts[g][a], tag) end function P:next() self:change_group(1) end function P:prev() self:change_group(-1) end function P:next_alt() self:change_alt(1) end function P:prev_alt() self:change_alt(-1) end return P