summaryrefslogtreecommitdiff
path: root/awesome/lain/layout
diff options
context:
space:
mode:
Diffstat (limited to 'awesome/lain/layout')
-rw-r--r--awesome/lain/layout/cascade.lua80
-rw-r--r--awesome/lain/layout/cascadetile.lua167
-rw-r--r--awesome/lain/layout/centerfair.lua163
-rw-r--r--awesome/lain/layout/centerwork.lua131
-rw-r--r--awesome/lain/layout/init.lua20
-rw-r--r--awesome/lain/layout/termfair.lua138
-rw-r--r--awesome/lain/layout/uselessfair.lua108
-rw-r--r--awesome/lain/layout/uselessfairnogap.lua108
-rw-r--r--awesome/lain/layout/uselesspiral.lua123
-rw-r--r--awesome/lain/layout/uselesstile.lua226
10 files changed, 1264 insertions, 0 deletions
diff --git a/awesome/lain/layout/cascade.lua b/awesome/lain/layout/cascade.lua
new file mode 100644
index 0000000..999c599
--- /dev/null
+++ b/awesome/lain/layout/cascade.lua
@@ -0,0 +1,80 @@
+
+--[[
+
+ Licensed under GNU General Public License v2
+ * (c) 2014, projektile
+ * (c) 2013, Luke Bonham
+ * (c) 2010-2012, Peter Hofmann
+
+--]]
+
+local tag = require("awful.tag")
+local beautiful = require("beautiful")
+
+local cascade =
+{
+ name = "cascade",
+ nmaster = 0,
+ offset_x = 32,
+ offset_y = 8
+}
+
+function cascade.arrange(p)
+
+ -- Cascade windows.
+
+ -- A global border can be defined with
+ -- beautiful.global_border_width.
+ local global_border = tonumber(beautiful.global_border_width) or 0
+ if global_border < 0 then global_border = 0 end
+
+ -- Themes border width requires an offset.
+ local bw = tonumber(beautiful.border_width) or 0
+
+ -- Screen.
+ local wa = p.workarea
+ local cls = p.clients
+
+ wa.height = wa.height - ((global_border * 2) + (bw * 2))
+ wa.width = wa.width - ((global_border * 2) + (bw * 2))
+ wa.x = wa.x + global_border
+ wa.y = wa.y + global_border
+
+ -- Opening a new window will usually force all existing windows to
+ -- get resized. This wastes a lot of CPU time. So let's set a lower
+ -- bound to "how_many": This wastes a little screen space but you'll
+ -- get a much better user experience.
+ local t = tag.selected(p.screen)
+ local num_c
+ if cascade.nmaster > 0
+ then
+ num_c = cascade.nmaster
+ else
+ num_c = tag.getnmaster(t)
+ end
+
+ local how_many = #cls
+ if how_many < num_c
+ then
+ how_many = num_c
+ end
+
+ local current_offset_x = cascade.offset_x * (how_many - 1)
+ local current_offset_y = cascade.offset_y * (how_many - 1)
+
+ -- Iterate.
+ for i = 1,#cls,1
+ do
+ local c = cls[i]
+ local g = {}
+
+ g.x = wa.x + (how_many - i) * cascade.offset_x
+ g.y = wa.y + (i - 1) * cascade.offset_y
+ g.width = wa.width - current_offset_x
+ g.height = wa.height - current_offset_y
+
+ c:geometry(g)
+ end
+end
+
+return cascade
diff --git a/awesome/lain/layout/cascadetile.lua b/awesome/lain/layout/cascadetile.lua
new file mode 100644
index 0000000..e9b9425
--- /dev/null
+++ b/awesome/lain/layout/cascadetile.lua
@@ -0,0 +1,167 @@
+
+--[[
+
+ Licensed under GNU General Public License v2
+ * (c) 2014, projektile
+ * (c) 2013, Luke Bonham
+ * (c) 2010-2012, Peter Hofmann
+
+--]]
+
+local tag = require("awful.tag")
+local beautiful = require("beautiful")
+local tonumber = tonumber
+
+local cascadetile =
+{
+ name = "cascadetile",
+ nmaster = 0,
+ ncol = 0,
+ mwfact = 0,
+ offset_x = 5,
+ offset_y = 32,
+ extra_padding = 0
+}
+
+function cascadetile.arrange(p)
+
+ -- Layout with one fixed column meant for a master window. Its
+ -- width is calculated according to mwfact. Other clients are
+ -- cascaded or "tabbed" in a slave column on the right.
+
+ -- It's a bit hard to demonstrate the behaviour with ASCII-images...
+ --
+ -- (1) (2) (3) (4)
+ -- +----------+---+ +----------+---+ +----------+---+ +----------+---+
+ -- | | | | | 3 | | | 4 | | +---+|
+ -- | | | -> | | | -> | +---++ -> | +---+|+
+ -- | 1 | 2 | | 1 +---++ | 1 | 3 || | 1 +---+|+|
+ -- | | | | | 2 || | +---++| | +---+|+ |
+ -- | | | | | || | | 2 | | | | 2 |+ |
+ -- +----------+---+ +---------+---++ +--------+---+-+ +------+---+---+
+
+ -- A useless gap (like the dwm patch) can be defined with
+ -- beautiful.useless_gap_width.
+ local useless_gap = tonumber(beautiful.useless_gap_width) or 0
+ if useless_gap < 0 then useless_gap = 0 end
+
+ -- A global border can be defined with
+ -- beautiful.global_border_width
+ local global_border = tonumber(beautiful.global_border_width) or 0
+ if global_border < 0 then global_border = 0 end
+
+ -- Themes border width requires an offset
+ local bw = tonumber(beautiful.border_width) or 0
+
+ -- Screen.
+ local wa = p.workarea
+ local cls = p.clients
+
+ -- Borders are factored in.
+ wa.height = wa.height - ((global_border * 2) + (bw * 2))
+ wa.width = wa.width - ((global_border * 2) + (bw * 2))
+
+ -- Width of main column?
+ local t = tag.selected(p.screen)
+ local mwfact
+ if cascadetile.mwfact > 0
+ then
+ mwfact = cascadetile.mwfact
+ else
+ mwfact = tag.getmwfact(t)
+ end
+
+ -- Make slave windows overlap main window? Do this if ncol is 1.
+ local overlap_main
+ if cascadetile.ncol > 0
+ then
+ overlap_main = cascadetile.ncol
+ else
+ overlap_main = tag.getncol(t)
+ end
+
+ -- Minimum space for slave windows? See cascade.lua.
+ local num_c
+ if cascadetile.nmaster > 0
+ then
+ num_c = cascadetile.nmaster
+ else
+ num_c = tag.getnmaster(t)
+ end
+
+ local how_many = #cls - 1
+ if how_many < num_c
+ then
+ how_many = num_c
+ end
+ local current_offset_x = cascadetile.offset_x * (how_many - 1)
+ local current_offset_y = cascadetile.offset_y * (how_many - 1)
+
+ if #cls > 0
+ then
+ -- Main column, fixed width and height.
+ local c = cls[#cls]
+ local g = {}
+ local mainwid = wa.width * mwfact
+ local slavewid = wa.width - mainwid
+
+ if overlap_main == 1
+ then
+ g.width = wa.width
+
+ -- The size of the main window may be reduced a little bit.
+ -- This allows you to see if there are any windows below the
+ -- main window.
+ -- This only makes sense, though, if the main window is
+ -- overlapping everything else.
+ g.width = g.width - cascadetile.extra_padding
+ else
+ g.width = mainwid
+ end
+
+ g.height = wa.height
+ g.x = wa.x + global_border
+ g.y = wa.y + global_border
+ if useless_gap > 0
+ then
+ -- Reduce width once and move window to the right. Reduce
+ -- height twice, however.
+ g.width = g.width - useless_gap
+ g.height = g.height - 2 * useless_gap
+ g.x = g.x + useless_gap
+ g.y = g.y + useless_gap
+
+ -- When there's no window to the right, add an additional
+ -- gap.
+ if overlap_main == 1
+ then
+ g.width = g.width - useless_gap
+ end
+ end
+ c:geometry(g)
+
+ -- Remaining clients stacked in slave column, new ones on top.
+ if #cls > 1
+ then
+ for i = (#cls - 1),1,-1
+ do
+ c = cls[i]
+ g = {}
+ g.width = slavewid - current_offset_x
+ g.height = wa.height - current_offset_y
+ g.x = wa.x + mainwid + (how_many - i) * cascadetile.offset_x
+ g.y = wa.y + (i - 1) * cascadetile.offset_y + global_border
+ if useless_gap > 0
+ then
+ g.width = g.width - 2 * useless_gap
+ g.height = g.height - 2 * useless_gap
+ g.x = g.x + useless_gap
+ g.y = g.y + useless_gap
+ end
+ c:geometry(g)
+ end
+ end
+ end
+end
+
+return cascadetile
diff --git a/awesome/lain/layout/centerfair.lua b/awesome/lain/layout/centerfair.lua
new file mode 100644
index 0000000..1e8915d
--- /dev/null
+++ b/awesome/lain/layout/centerfair.lua
@@ -0,0 +1,163 @@
+
+--[[
+
+ Licensed under GNU General Public License v2
+ * (c) 2014, projektile
+ * (c) 2013, Luke Bonham
+ * (c) 2010, Nicolas Estibals
+ * (c) 2010-2012, Peter Hofmann
+
+--]]
+
+local tag = require("awful.tag")
+local beautiful = require("beautiful")
+local math = { ceil = math.ceil,
+ floor = math.floor,
+ max = math.max }
+local tonumber = tonumber
+
+local centerfair = { name = "centerfair" }
+
+function centerfair.arrange(p)
+ -- Layout with fixed number of vertical columns (read from nmaster).
+ -- Cols are centerded until there is nmaster columns, then windows
+ -- are stacked in the slave columns, with at most ncol clients per
+ -- column if possible.
+
+ -- with nmaster=3 and ncol=1 you'll have
+ -- (1) (2) (3)
+ -- +---+---+---+ +-+---+---+-+ +---+---+---+
+ -- | | | | | | | | | | | | |
+ -- | | 1 | | -> | | 1 | 2 | | -> | 1 | 2 | 3 | ->
+ -- | | | | | | | | | | | | |
+ -- +---+---+---+ +-+---+---+-+ +---+---+---+
+
+ -- (4) (5)
+ -- +---+---+---+ +---+---+---+
+ -- | | | 3 | | | 2 | 4 |
+ -- + 1 + 2 +---+ -> + 1 +---+---+
+ -- | | | 4 | | | 3 | 5 |
+ -- +---+---+---+ +---+---+---+
+
+ -- A useless gap (like the dwm patch) can be defined with
+ -- beautiful.useless_gap_width .
+ local useless_gap = tonumber(beautiful.useless_gap_width) or 0
+ if useless_gap < 0 then useless_gap = 0 end
+
+ -- A global border can be defined with
+ -- beautiful.global_border_width
+ local global_border = tonumber(beautiful.global_border_width) or 0
+ if global_border < 0 then global_border = 0 end
+
+ -- Themes border width requires an offset
+ local bw = tonumber(beautiful.border_width) or 0
+
+ -- Screen.
+ local wa = p.workarea
+ local cls = p.clients
+
+ -- Borders are factored in.
+ wa.height = wa.height - ((global_border * 2) + (bw * 2))
+ wa.width = wa.width - ((global_border * 2) + (bw * 2))
+
+ -- How many vertical columns? Read from nmaster on the tag.
+ local t = tag.selected(p.screen)
+ local num_x = centerfair.nmaster or tag.getnmaster(t)
+ local ncol = centerfair.ncol or tag.getncol(t)
+ if num_x <= 2 then num_x = 2 end
+
+ local width = math.floor((wa.width-(num_x+1)*useless_gap) / num_x)
+
+ local offset_y = wa.y + useless_gap
+ if #cls < num_x
+ then
+ -- Less clients than the number of columns, let's center it!
+ local offset_x = wa.x + useless_gap + (wa.width - #cls*width - (#cls+1)*useless_gap) / 2
+ local g = {}
+ g.width = width
+ g.height = wa.height - 2*useless_gap - 2
+ g.y = offset_y + global_border
+ for i = 1, #cls do
+ g.x = offset_x + (#cls - i) * (width + useless_gap + 2) + global_border
+ cls[i]:geometry(g)
+ end
+ else
+ -- More clients than the number of columns, let's arrange it!
+ local offset_x = wa.x
+ if useless_gap > 0 then
+ offset_x = offset_x
+ end
+
+ -- Master client deserves a special treatement
+ local g = {}
+ g.width = wa.width - (num_x - 1) * width - num_x * 2*useless_gap - 2
+ g.height = wa.height - 2*useless_gap - 2
+ g.x = offset_x + useless_gap + global_border
+ g.y = offset_y + global_border
+
+ cls[#cls]:geometry(g)
+
+ -- Treat the other clients
+
+ -- Compute distribution of clients among columns
+ local num_y ={}
+ do
+ local remaining_clients = #cls-1
+ local ncol_min = math.ceil(remaining_clients/(num_x-1))
+ if ncol >= ncol_min
+ then
+ for i = (num_x-1), 1, -1 do
+ if (remaining_clients-i+1) < ncol
+ then
+ num_y[i] = remaining_clients-i + 1
+ else
+ num_y[i] = ncol
+ end
+ remaining_clients = remaining_clients - num_y[i]
+ end
+ else
+ local rem = remaining_clients % (num_x-1)
+ if rem ==0
+ then
+ for i = 1, num_x-1 do
+ num_y[i] = ncol_min
+ end
+ else
+ for i = 1, num_x-1 do
+ num_y[i] = ncol_min - 1
+ end
+ for i = 0, rem-1 do
+ num_y[num_x-1-i] = num_y[num_x-1-i] + 1
+ end
+ end
+ end
+ end
+
+ -- Compute geometry of the other clients
+ local nclient = #cls-1 -- we start with the 2nd client
+ g.x = g.x + g.width+useless_gap + 2
+ g.width = width
+
+ if useless_gap > 0 then
+ g.width = g.width + useless_gap - 2
+ end
+
+ for i = 1, (num_x-1) do
+ to_remove = 2
+ g.height = math.floor((wa.height - (num_y[i] * useless_gap)) / num_y[i])
+ g.y = offset_y + global_border
+ for j = 0, (num_y[i]-2) do
+ cls[nclient]:geometry(g)
+ nclient = nclient - 1
+ g.y = g.y + g.height+useless_gap + 2
+ to_remove = to_remove + 2
+ end
+ g.height = wa.height - num_y[i]*useless_gap - (num_y[i]-1)*g.height - useless_gap - to_remove
+ cls[nclient]:geometry(g)
+ nclient = nclient - 1
+ g.x = g.x+g.width+useless_gap + 2
+ end
+ end
+end
+
+return centerfair
diff --git a/awesome/lain/layout/centerwork.lua b/awesome/lain/layout/centerwork.lua
new file mode 100644
index 0000000..61f4907
--- /dev/null
+++ b/awesome/lain/layout/centerwork.lua
@@ -0,0 +1,131 @@
+
+--[[
+
+ Licensed under GNU General Public License v2
+ * (c) 2014, projektile
+ * (c) 2013, Luke Bonham
+ * (c) 2010-2012, Peter Hofmann
+
+--]]
+
+local awful = require("awful")
+local beautiful = require("beautiful")
+local tonumber = tonumber
+local math = { floor = math.floor }
+
+local centerwork =
+{
+ name = "centerwork",
+ top_left = 0,
+ top_right = 1,
+ bottom_left = 2,
+ bottom_right = 3
+}
+
+function centerwork.arrange(p)
+ -- A useless gap (like the dwm patch) can be defined with
+ -- beautiful.useless_gap_width .
+ local useless_gap = tonumber(beautiful.useless_gap_width) or 0
+
+ -- A global border can be defined with
+ -- beautiful.global_border_width
+ local global_border = tonumber(beautiful.global_border_width) or 0
+ if global_border < 0 then global_border = 0 end
+
+ -- Themes border width requires an offset
+ local bw = tonumber(beautiful.border_width) or 0
+
+ -- Screen.
+ local wa = p.workarea
+ local cls = p.clients
+
+ -- Borders are factored in.
+ wa.height = wa.height - ((global_border * 2) + (bw * 2))
+ wa.width = wa.width - ((global_border * 2) + (bw * 2))
+
+ -- Width of main column?
+ local t = awful.tag.selected(p.screen)
+ local mwfact = awful.tag.getmwfact(t)
+
+ if #cls > 0
+ then
+ -- Main column, fixed width and height.
+ local c = cls[#cls]
+ local g = {}
+ local mainwid = math.floor(wa.width * mwfact)
+ local slavewid = wa.width - mainwid
+ local slaveLwid = math.floor(slavewid / 2)
+ local slaveRwid = slavewid - slaveLwid
+ local slaveThei = math.floor(wa.height / 2)
+ local slaveBhei = wa.height - slaveThei
+
+ g.height = wa.height - 2 * useless_gap
+ g.width = mainwid
+ g.x = wa.x + slaveLwid + global_border
+ g.y = wa.y + useless_gap + global_border
+
+ c:geometry(g)
+
+ -- Auxiliary windows.
+ if #cls > 1
+ then
+ local at = 0
+ for i = (#cls - 1),1,-1
+ do
+ -- It's all fixed. If there are more than 5 clients,
+ -- those additional clients will float. This is
+ -- intentional.
+ if at == 4
+ then
+ break
+ end
+
+ c = cls[i]
+ g = {}
+
+ if at == centerwork.top_left
+ then
+ -- top left
+ g.x = wa.x + useless_gap + global_border
+ g.y = wa.y + useless_gap + global_border
+ g.width = slaveLwid - 2 * useless_gap
+ g.height = slaveThei - useless_gap
+ elseif at == centerwork.top_right
+ then
+ -- top right
+ g.x = wa.x + slaveLwid + mainwid + useless_gap + global_border
+ g.y = wa.y + useless_gap + global_border
+ g.width = slaveRwid - 2 * useless_gap
+ g.height = slaveThei - useless_gap
+ elseif at == centerwork.bottom_left
+ then
+ -- bottom left
+ g.x = wa.x + useless_gap + global_border
+ g.y = wa.y + slaveThei + useless_gap + global_border
+ g.width = slaveLwid - 2 * useless_gap
+ g.height = slaveBhei - 2 * useless_gap
+ elseif at == centerwork.bottom_right
+ then
+ -- bottom right
+ g.x = wa.x + slaveLwid + mainwid + useless_gap + global_border
+ g.y = wa.y + slaveThei + useless_gap + global_border
+ g.width = slaveRwid - 2 * useless_gap
+ g.height = slaveBhei - 2 * useless_gap
+ end
+
+ c:geometry(g)
+
+ at = at + 1
+ end
+
+ -- Set remaining clients to floating.
+ for i = (#cls - 1 - 4),1,-1
+ do
+ c = cls[i]
+ awful.client.floating.set(c, true)
+ end
+ end
+ end
+end
+
+return centerwork
diff --git a/awesome/lain/layout/init.lua b/awesome/lain/layout/init.lua
new file mode 100644
index 0000000..d79679a
--- /dev/null
+++ b/awesome/lain/layout/init.lua
@@ -0,0 +1,20 @@
+
+--[[
+
+ Lain
+ Layouts, widgets and utilities for Awesome WM
+
+ Layouts section
+
+ Licensed under GNU General Public License v2
+ * (c) 2013, Luke Bonham
+ * (c) 2010-2012, Peter Hofmann
+
+--]]
+
+local wrequire = require("lain.helpers").wrequire
+local setmetatable = setmetatable
+
+local layout = { _NAME = "lain.layout" }
+
+return setmetatable(layout, { __index = wrequire })
diff --git a/awesome/lain/layout/termfair.lua b/awesome/lain/layout/termfair.lua
new file mode 100644
index 0000000..4e45eec
--- /dev/null
+++ b/awesome/lain/layout/termfair.lua
@@ -0,0 +1,138 @@
+
+--[[
+
+ Licensed under GNU General Public License v2
+ * (c) 2014, projektile
+ * (c) 2013, Luke Bonham
+ * (c) 2010-2012, Peter Hofmann
+
+--]]
+
+local tag = require("awful.tag")
+local beautiful = require("beautiful")
+local math = { ceil = math.ceil,
+ floor = math.floor,
+ max = math.max }
+local tonumber = tonumber
+
+local termfair = { name = "termfair" }
+
+function termfair.arrange(p)
+ -- Layout with fixed number of vertical columns (read from nmaster).
+ -- New windows align from left to right. When a row is full, a now
+ -- one above it is created. Like this:
+
+ -- (1) (2) (3)
+ -- +---+---+---+ +---+---+---+ +---+---+---+
+ -- | | | | | | | | | | | |
+ -- | 1 | | | -> | 2 | 1 | | -> | 3 | 2 | 1 | ->
+ -- | | | | | | | | | | | |
+ -- +---+---+---+ +---+---+---+ +---+---+---+
+
+ -- (4) (5) (6)
+ -- +---+---+---+ +---+---+---+ +---+---+---+
+ -- | 4 | | | | 5 | 4 | | | 6 | 5 | 4 |
+ -- +---+---+---+ -> +---+---+---+ -> +---+---+---+
+ -- | 3 | 2 | 1 | | 3 | 2 | 1 | | 3 | 2 | 1 |
+ -- +---+---+---+ +---+---+---+ +---+---+---+
+
+ -- A useless gap (like the dwm patch) can be defined with
+ -- beautiful.useless_gap_width.
+ local useless_gap = tonumber(beautiful.useless_gap_width) or 0
+ if useless_gap < 0 then useless_gap = 0 end
+
+ -- A global border can be defined with
+ -- beautiful.global_border_width
+ local global_border = tonumber(beautiful.global_border_width) or 0
+ if global_border < 0 then global_border = 0 end
+
+ -- Themes border width requires an offset
+ local bw = tonumber(beautiful.border_width) or 0
+
+ -- Screen.
+ local wa = p.workarea
+ local cls = p.clients
+
+ -- Borders are factored in.
+ wa.height = wa.height - ((global_border * 2) + (bw * 2))
+ wa.width = wa.width - ((global_border * 2) + (bw * 2))
+
+ -- How many vertical columns?
+ local t = tag.selected(p.screen)
+ local num_x = termfair.nmaster or tag.getnmaster(t)
+
+ -- Do at least "desired_y" rows.
+ local desired_y = termfair.ncol or tag.getncol(t)
+
+ if #cls > 0
+ then
+ local num_y = math.max(math.ceil(#cls / num_x), desired_y)
+ local cur_num_x = num_x
+ local at_x = 0
+ local at_y = 0
+ local remaining_clients = #cls
+ local width = math.floor(wa.width / num_x)
+ local height = math.floor(wa.height / num_y)
+
+ -- We start the first row. Left-align by limiting the number of
+ -- available slots.
+ if remaining_clients < num_x
+ then
+ cur_num_x = remaining_clients
+ end
+
+ -- Iterate in reversed order.
+ for i = #cls,1,-1
+ do
+ -- Get x and y position.
+ local c = cls[i]
+ local this_x = cur_num_x - at_x - 1
+ local this_y = num_y - at_y - 1
+
+ -- Calc geometry.
+ local g = {}
+ if this_x == (num_x - 1)
+ then
+ g.width = wa.width - (num_x - 1) * width - useless_gap
+ else
+ g.width = width - useless_gap
+ end
+ if this_y == (num_y - 1)
+ then
+ g.height = wa.height - (num_y - 1) * height - useless_gap
+ else
+ g.height = height - useless_gap
+ end
+
+ g.x = wa.x + this_x * width + global_border
+ g.y = wa.y + this_y * height + global_border
+
+ if useless_gap > 0
+ then
+ -- All clients tile evenly.
+ g.x = g.x + (useless_gap / 2)
+ g.y = g.y + (useless_gap / 2)
+
+ end
+ c:geometry(g)
+ remaining_clients = remaining_clients - 1
+
+ -- Next grid position.
+ at_x = at_x + 1
+ if at_x == num_x
+ then
+ -- Row full, create a new one above it.
+ at_x = 0
+ at_y = at_y + 1
+
+ -- We start a new row. Left-align.
+ if remaining_clients < num_x
+ then
+ cur_num_x = remaining_clients
+ end
+ end
+ end
+ end
+end
+
+return termfair
diff --git a/awesome/lain/layout/uselessfair.lua b/awesome/lain/layout/uselessfair.lua
new file mode 100644
index 0000000..e1284e0
--- /dev/null
+++ b/awesome/lain/layout/uselessfair.lua
@@ -0,0 +1,108 @@
+
+--[[
+
+ Licensed under GNU General Public License v2
+ * (c) 2014, projektile, worron
+ * (c) 2013, Luke Bonham
+ * (c) 2012, Josh Komoroske
+ * (c) 2010-2012, Peter Hofmann
+
+--]]
+
+local beautiful = require("beautiful")
+local ipairs = ipairs
+local math = { ceil = math.ceil, sqrt = math.sqrt, floor = math.floor, max = math.max }
+local tonumber = tonumber
+
+local uselessfair = {}
+
+-- Transformation functions
+local function swap(geometry)
+ return { x = geometry.y, y = geometry.x, width = geometry.height, height = geometry.width }
+end
+
+-- Client geometry correction depending on useless gap and window border
+local function size_correction(c, geometry, useless_gap)
+ geometry.width = math.max(geometry.width - 2 * c.border_width - useless_gap, 1)
+ geometry.height = math.max(geometry.height - 2 * c.border_width - useless_gap, 1)
+ geometry.x = geometry.x + useless_gap / 2
+ geometry.y = geometry.y + useless_gap / 2
+end
+
+-- Main tiling function
+local function fair(p, orientation)
+
+ -- Theme vars
+ local useless_gap = beautiful.useless_gap_width or 0
+ local global_border = beautiful.global_border_width or 0
+
+ -- Aliases
+ local wa = p.workarea
+ local cls = p.clients
+
+ -- Nothing to tile here
+ if #cls == 0 then return end
+
+ -- Workarea size correction depending on useless gap and global border
+ wa.height = wa.height - 2 * global_border - useless_gap
+ wa.width = wa.width - 2 * global_border - useless_gap
+ wa.x = wa.x + useless_gap / 2 + global_border
+ wa.y = wa.y + useless_gap / 2 + global_border
+
+ -- Geometry calculation
+ local row, col = 0, 0
+
+ local rows = math.ceil(math.sqrt(#cls))
+ local cols = math.ceil(#cls / rows)
+
+ for i, c in ipairs(cls) do
+ local g = {}
+
+ -- find tile orientation for current client and swap geometry if need
+ local need_swap = (orientation == "east" and #cls <= 2) or (orientation == "south" and #cls > 2)
+ local area = need_swap and swap(wa) or wa
+
+ -- calculate geometry
+ if #cls < (cols * rows) and row == cols - 1 then
+ g.width = area.width / (rows - ((cols * rows) - #cls))
+ else
+ g.width = area.width / rows
+ end
+
+ g.height = area.height / cols
+ g.x = area.x + col * g.width
+ g.y = area.y + row * g.height
+
+ -- turn back to real if geometry was swapped
+ if need_swap then g = swap(g) end
+
+ -- window size correction depending on useless gap and window border
+ size_correction(c, g, useless_gap)
+
+ -- set geometry
+ c:geometry(g)
+
+ -- update tile grid coordinates
+ col = i % rows
+ row = math.floor(i / rows)
+ end
+end
+
+-- Layout constructor
+local function construct_layout(name, direction)
+ return {
+ name = name,
+ -- @p screen The screen number to tile
+ arrange = function(p) return fair(p, direction) end
+ }
+end
+
+-- Build layouts with different tile direction
+uselessfair.vertical = construct_layout("uselessfair", "south")
+uselessfair.horizontal = construct_layout("uselessfairh", "east")
+
+-- Module aliase
+uselessfair.arrange = uselessfair.vertical.arrange
+uselessfair.name = uselessfair.vertical.name
+
+return uselessfair
diff --git a/awesome/lain/layout/uselessfairnogap.lua b/awesome/lain/layout/uselessfairnogap.lua
new file mode 100644
index 0000000..6599a89
--- /dev/null
+++ b/awesome/lain/layout/uselessfairnogap.lua
@@ -0,0 +1,108 @@
+
+--[[
+
+ Licensed under GNU General Public License v2
+ * (c) 2014, projektile, worron
+ * (c) 2013, Luke Bonham
+ * (c) 2012, Josh Komoroske
+ * (c) 2010-2012, Peter Hofmann
+
+--]]
+
+local beautiful = require("beautiful")
+local ipairs = ipairs
+local math = { ceil = math.ceil, sqrt = math.sqrt, floor = math.floor, max = math.max }
+local tonumber = tonumber
+
+local uselessfair = {}
+
+-- Transformation functions
+local function swap(geometry)
+ return { x = geometry.y, y = geometry.x, width = geometry.height, height = geometry.width }
+end
+
+-- Client geometry correction depending on useless gap and window border
+local function size_correction(c, geometry, useless_gap)
+ geometry.width = math.max(geometry.width - 2 * c.border_width - useless_gap, 1)
+ geometry.height = math.max(geometry.height - 2 * c.border_width - useless_gap, 1)
+ geometry.x = geometry.x + useless_gap / 2
+ geometry.y = geometry.y + useless_gap / 2
+end
+
+-- Main tiling function
+local function fair(p, orientation)
+
+ -- Theme vars
+ local useless_gap = 0
+ local global_border = 1
+
+ -- Aliases
+ local wa = p.workarea
+ local cls = p.clients
+
+ -- Nothing to tile here
+ if #cls == 0 then return end
+
+ -- Workarea size correction depending on useless gap and global border
+ wa.height = wa.height - 2 * global_border - useless_gap
+ wa.width = wa.width - 2 * global_border - useless_gap
+ wa.x = wa.x + useless_gap / 2 + global_border
+ wa.y = wa.y + useless_gap / 2 + global_border
+
+ -- Geometry calculation
+ local row, col = 0, 0
+
+ local rows = math.ceil(math.sqrt(#cls))
+ local cols = math.ceil(#cls / rows)
+
+ for i, c in ipairs(cls) do
+ local g = {}
+
+ -- find tile orientation for current client and swap geometry if need
+ local need_swap = (orientation == "east" and #cls <= 2) or (orientation == "south" and #cls > 2)
+ local area = need_swap and swap(wa) or wa
+
+ -- calculate geometry
+ if #cls < (cols * rows) and row == cols - 1 then
+ g.width = area.width / (rows - ((cols * rows) - #cls))
+ else
+ g.width = area.width / rows
+ end
+
+ g.height = area.height / cols
+ g.x = area.x + col * g.width
+ g.y = area.y + row * g.height
+
+ -- turn back to real if geometry was swapped
+ if need_swap then g = swap(g) end
+
+ -- window size correction depending on useless gap and window border
+ size_correction(c, g, useless_gap)
+
+ -- set geometry
+ c:geometry(g)
+
+ -- update tile grid coordinates
+ col = i % rows
+ row = math.floor(i / rows)
+ end
+end
+
+-- Layout constructor
+local function construct_layout(name, direction)
+ return {
+ name = name,
+ -- @p screen The screen number to tile
+ arrange = function(p) return fair(p, direction) end
+ }
+end
+
+-- Build layouts with different tile direction
+uselessfair.vertical = construct_layout("uselessfair", "south")
+uselessfair.horizontal = construct_layout("uselessfairh", "east")
+
+-- Module aliase
+uselessfair.arrange = uselessfair.vertical.arrange
+uselessfair.name = uselessfair.vertical.name
+
+return uselessfair
diff --git a/awesome/lain/layout/uselesspiral.lua b/awesome/lain/layout/uselesspiral.lua
new file mode 100644
index 0000000..c388961
--- /dev/null
+++ b/awesome/lain/layout/uselesspiral.lua
@@ -0,0 +1,123 @@
+
+--[[
+
+ Licensed under GNU General Public License v2
+ * (c) 2014, projektile
+ * (c) 2013, Luke Bonham
+ * (c) 2009, Uli Schlachter
+ * (c) 2008, Julien Danjolu
+
+--]]
+
+local beautiful = require("beautiful")
+local ipairs = ipairs
+local tonumber = tonumber
+local math = require("math")
+
+local uselesspiral = {}
+
+local function spiral(p, spiral)
+ -- A useless gap (like the dwm patch) can be defined with
+ -- beautiful.useless_gap_width.
+ local useless_gap = tonumber(beautiful.useless_gap_width) or 0
+ if useless_gap < 0 then useless_gap = 0 end
+
+ -- A global border can be defined with
+ -- beautiful.global_border_width
+ local global_border = tonumber(beautiful.global_border_width) or 0
+ if global_border < 0 then global_border = 0 end
+
+ -- Themes border width requires an offset
+ local bw = tonumber(beautiful.border_width) or 0
+
+ -- get our orientation right
+ local wa = p.workarea
+ local cls = p.clients
+ local n = #cls -- number of windows total; k = which window number
+
+ wa.height = wa.height - ((global_border * 2) + (bw * 2))
+ wa.width = wa.width - ((global_border * 2) + (bw * 2))
+
+ local static_wa = wa
+
+ for k, c in ipairs(cls) do
+ if k < n then
+ if k % 2 == 0 then
+ wa.height = (wa.height / 2)
+ else
+ wa.width = (wa.width / 2)
+ end
+ end
+
+ if k % 4 == 0 and spiral then
+ wa.x = wa.x - wa.width
+ elseif k % 2 == 0 or
+ (k % 4 == 3 and k < n and spiral) then
+ wa.x = wa.x + wa.width
+ end
+
+ if k % 4 == 1 and k ~= 1 and spiral then
+ wa.y = wa.y - wa.height
+ elseif k % 2 == 1 and k ~= 1 or
+ (k % 4 == 0 and k < n and spiral) then
+ wa.y = wa.y + wa.height
+ end
+
+ local wa2 = {}
+ wa2.x = wa.x + (useless_gap / 2) + global_border
+ wa2.y = wa.y + (useless_gap / 2) + global_border
+ wa2.height = wa.height - (useless_gap / 2)
+ wa2.width = wa.width - (useless_gap / 2)
+
+ -- Useless gap.
+ if useless_gap > 0
+ then
+ -- Top and left clients are shrinked by two steps and
+ -- get moved away from the border. Other clients just
+ -- get shrinked in one direction.
+
+ top = false
+ left = false
+
+ if wa2.y == static_wa.y then
+ top = true
+ end
+
+ if wa2.x == static_wa.x then
+ left = true
+ end
+
+ if top then
+ wa2.height = wa2.height - useless_gap
+ wa2.y = wa2.y - (useless_gap / 2)
+ else
+ wa2.height = wa2.height - (useless_gap / 2)
+ end
+
+ if left then
+ wa2.width = wa2.width - useless_gap
+ wa2.x = wa2.x - (useless_gap / 2)
+ else
+ wa2.width = wa2.width - (useless_gap / 2)
+ end
+ end
+ -- End of useless gap.
+
+ c:geometry(wa2)
+ end
+end
+
+--- Dwindle layout
+uselesspiral.dwindle = {}
+uselesspiral.dwindle.name = "uselessdwindle"
+function uselesspiral.dwindle.arrange(p)
+ return spiral(p, false)
+end
+
+--- Spiral layout
+uselesspiral.name = "uselesspiral"
+function uselesspiral.arrange(p)
+ return spiral(p, true)
+end
+
+return uselesspiral
diff --git a/awesome/lain/layout/uselesstile.lua b/awesome/lain/layout/uselesstile.lua
new file mode 100644
index 0000000..e48c85d
--- /dev/null
+++ b/awesome/lain/layout/uselesstile.lua
@@ -0,0 +1,226 @@
+
+--[[
+
+ Licensed under GNU General Public License v2
+ * (c) 2014, projektile, worron
+ * (c) 2013, Luke Bonham
+ * (c) 2009, Donald Ephraim Curtis
+ * (c) 2008, Julien Danjolu
+
+--]]
+
+local tag = require("awful.tag")
+local beautiful = require("beautiful")
+local ipairs = ipairs
+local math = { floor = math.floor,
+ ceil = math.ceil,
+ max = math.max,
+ min = math.min }
+local tonumber = tonumber
+
+local uselesstile = {}
+
+-- Transformation functions
+local function flip(canvas, geometry)
+ return {
+ -- vertical only
+ x = 2 * canvas.x + canvas.width - geometry.x - geometry.width,
+ y = geometry.y,
+ width = geometry.width,
+ height = geometry.height
+ }
+end
+
+local function swap(geometry)
+ return { x = geometry.y, y = geometry.x, width = geometry.height, height = geometry.width }
+end
+
+-- Find geometry for secondary windows column
+local function cut_column(wa, n, index)
+ local width = wa.width / n
+ local area = { x = wa.x + (index - 1) * width, y = wa.y, width = width, height = wa.height }
+
+ return area
+end
+
+-- Find geometry for certain window in column
+local function cut_row(wa, factor, index, used)
+ local height = wa.height * factor.window[index] / factor.total
+ local area = { x = wa.x, y = wa.y + used, width = wa.width, height = height }
+
+ return area
+end
+
+-- Client geometry correction depending on useless gap and window border
+local function size_correction(c, geometry, useless_gap)
+ geometry.width = math.max(geometry.width - 2 * c.border_width - useless_gap, 1)
+ geometry.height = math.max(geometry.height - 2 * c.border_width - useless_gap, 1)
+ geometry.x = geometry.x + useless_gap / 2
+ geometry.y = geometry.y + useless_gap / 2
+end
+
+-- Check size factor for group of clients and calculate total
+local function calc_factor(n, winfactors)
+ local factor = { window = winfactors, total = 0, min = 1 }
+
+ for i = 1, n do
+ if not factor.window[i] then
+ factor.window[i] = factor.min
+ else
+ factor.min = math.min(factor.window[i], factor.min)
+ if factor.window[i] < 0.05 then factor.window[i] = 0.05 end
+ end
+ factor.total = factor.total + factor.window[i]
+ end
+
+ return factor
+end
+
+-- Tile group of clients in given area
+-- @canvas need for proper transformation only
+-- @winfactors table with clients size factors
+local function tile_column(canvas, area, list, useless_gap, transformation, winfactors)
+ local used = 0
+ local factor = calc_factor(#list, winfactors)
+
+ for i, c in ipairs(list) do
+ local g = cut_row(area, factor, i, used)
+ used = used + g.height
+
+ -- swap workarea dimensions
+ if transformation.flip then g = flip(canvas, g) end
+ if transformation.swap then g = swap(g) end
+
+ -- useless gap and border correction
+ size_correction(c, g, useless_gap)
+
+ c:geometry(g)
+ end
+end
+
+--Main tile function
+local function tile(p, orientation)
+
+ -- Theme vars
+ local useless_gap = beautiful.useless_gap_width or 0
+ local global_border = beautiful.global_border_width or 0
+
+ -- Aliases
+ local wa = p.workarea
+ local cls = p.clients
+ local t = tag.selected(p.screen)
+
+ -- Nothing to tile here
+ if #cls == 0 then return end
+
+ -- Get tag prop
+ local nmaster = math.min(tag.getnmaster(t), #cls)
+ local mwfact = tag.getmwfact(t)
+
+ if nmaster == 0 then
+ mwfact = 0
+ elseif nmaster == #cls then
+ mwfact = 1
+ end
+
+ -- clients size factor
+ local data = tag.getdata(t).windowfact
+
+ if not data then
+ data = {}
+ tag.getdata(t).windowfact = data
+ end
+
+ -- Workarea size correction depending on useless gap and global border
+ wa.height = wa.height - 2 * global_border - useless_gap
+ wa.width = wa.width - 2 * global_border - useless_gap
+ wa.x = wa.x + useless_gap / 2 + global_border
+ wa.y = wa.y + useless_gap / 2 + global_border
+
+ -- Find which transformation we need for given orientation
+ local transformation = {
+ swap = orientation == 'top' or orientation == 'bottom',
+ flip = orientation == 'left' or orientation == 'top'
+ }
+
+ -- Swap workarea dimensions if orientation vertical
+ if transformation.swap then wa = swap(wa) end
+
+ -- Split master and other windows
+ local cls_master, cls_other = {}, {}
+
+ for i, c in ipairs(cls) do
+ if i <= nmaster then
+ table.insert(cls_master, c)
+ else
+ table.insert(cls_other, c)
+ end
+ end
+
+ -- Tile master windows
+ local master_area = {
+ x = wa.x,
+ y = wa.y,
+ width = nmaster > 0 and wa.width * mwfact or 0,
+ height = wa.height
+ }
+
+ if not data[0] then data[0] = {} end
+ tile_column(wa, master_area, cls_master, useless_gap, transformation, data[0])
+
+ -- Tile other windows
+ local other_area = {
+ x = wa.x + master_area.width,
+ y = wa.y,
+ width = wa.width - master_area.width,
+ height = wa.height
+ }
+
+ -- get column number for other windows
+ local ncol = math.min(tag.getncol(t), #cls_other)
+
+ if ncol == 0 then ncol = 1 end
+
+ -- split other windows to column groups
+ local last_small_column = ncol - #cls_other % ncol
+ local rows_min = math.floor(#cls_other / ncol)
+
+ local client_index = 1
+ for i = 1, ncol do
+ local position = transformation.flip and ncol - i + 1 or i
+ local rows = i <= last_small_column and rows_min or rows_min + 1
+ local column = {}
+
+ for j = 1, rows do
+ table.insert(column, cls_other[client_index])
+ client_index = client_index + 1
+ end
+
+ -- and tile
+ local column_area = cut_column(other_area, ncol, position)
+
+ if not data[i] then data[i] = {} end
+ tile_column(wa, column_area, column, useless_gap, transformation, data[i])
+ end
+end
+
+-- Layout constructor
+local function construct_layout(name, orientation)
+ return {
+ name = name,
+ -- @p screen number to tile
+ arrange = function(p) return tile(p, orientation) end
+ }
+end
+
+-- Build layouts with different tile direction
+uselesstile.right = construct_layout("uselesstile", "right")
+uselesstile.left = construct_layout("uselesstileleft", "left")
+uselesstile.bottom = construct_layout("uselesstilebottom", "bottom")
+uselesstile.top = construct_layout("uselesstiletop", "top")
+
+-- Module aliase
+uselesstile.arrange = uselesstile.right.arrange
+uselesstile.name = uselesstile.right.name
+
+return uselesstile