diff options
Diffstat (limited to '')
-rw-r--r-- | .config/awesome/lain/layout/cascade.lua | 65 | ||||
-rw-r--r-- | .config/awesome/lain/layout/cascadetile.lua | 155 | ||||
-rw-r--r-- | .config/awesome/lain/layout/centerfair.lua | 147 | ||||
-rw-r--r-- | .config/awesome/lain/layout/centerwork.lua | 118 | ||||
-rw-r--r-- | .config/awesome/lain/layout/init.lua | 20 | ||||
-rw-r--r-- | .config/awesome/lain/layout/termfair.lua | 141 | ||||
-rw-r--r-- | .config/awesome/lain/layout/uselessfair.lua | 121 | ||||
-rw-r--r-- | .config/awesome/lain/layout/uselesspiral.lua | 110 | ||||
-rw-r--r-- | .config/awesome/lain/layout/uselesstile.lua | 230 |
9 files changed, 1107 insertions, 0 deletions
diff --git a/.config/awesome/lain/layout/cascade.lua b/.config/awesome/lain/layout/cascade.lua new file mode 100644 index 0000000..cabacef --- /dev/null +++ b/.config/awesome/lain/layout/cascade.lua @@ -0,0 +1,65 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luke Bonham + * (c) 2010-2012, Peter Hofmann + +--]] + +local tag = require("awful.tag") + +local cascade = +{ + name = "cascade", + nmaster = 0, + offset_x = 32, + offset_y = 8 +} + +function cascade.arrange(p) + + -- Cascade windows. + + -- Screen. + local wa = p.workarea + local cls = p.clients + + -- 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/.config/awesome/lain/layout/cascadetile.lua b/.config/awesome/lain/layout/cascadetile.lua new file mode 100644 index 0000000..98821e3 --- /dev/null +++ b/.config/awesome/lain/layout/cascadetile.lua @@ -0,0 +1,155 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (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) + -- +-----+---+ +-----+---+ +-----+---+ +-----+---+ + -- | | | | | | | | | | | 4 | + -- | | | | | 2 | | | 3 | | | | + -- | 1 | | -> | 1 | | -> | 1 | | -> | 1 +---+ + -- | | | | +---+ | +---+ | | 3 | + -- | | | | | | | | 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 + + -- Screen. + local wa = p.workarea + local cls = p.clients + + -- 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 + g.y = wa.y + 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 + 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/.config/awesome/lain/layout/centerfair.lua b/.config/awesome/lain/layout/centerfair.lua new file mode 100644 index 0000000..49b4a14 --- /dev/null +++ b/.config/awesome/lain/layout/centerfair.lua @@ -0,0 +1,147 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (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 + + -- Screen. + local wa = p.workarea + local cls = p.clients + + -- 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) + + 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 + for i = 1, #cls do + g.x = offset_x + (i - 1) * (width + useless_gap + 2) + 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*useless_gap - 2 + g.height = wa.height - 2*useless_gap - 2 + g.x = offset_x + useless_gap + g.y = offset_y + cls[1]: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 = 2 + g.x = g.x + g.width+useless_gap + 2 + g.width = width + + if useless_gap > 0 then + g.width = g.width - useless_gap/2 - 2 + end + + for i = 1, (num_x-1) do + to_remove = 2 + g.height = math.floor((wa.height-useless_gap)/num_y[i]) + g.y = offset_y + 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/.config/awesome/lain/layout/centerwork.lua b/.config/awesome/lain/layout/centerwork.lua new file mode 100644 index 0000000..b8175ea --- /dev/null +++ b/.config/awesome/lain/layout/centerwork.lua @@ -0,0 +1,118 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (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 + + -- Screen. + local wa = p.workarea + local cls = p.clients + + -- 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 + g.y = wa.y + useless_gap + + 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 + g.y = wa.y + useless_gap + 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 + g.y = wa.y + useless_gap + 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 + g.y = wa.y + slaveThei + useless_gap + 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 + g.y = wa.y + slaveThei + useless_gap + 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/.config/awesome/lain/layout/init.lua b/.config/awesome/lain/layout/init.lua new file mode 100644 index 0000000..d79679a --- /dev/null +++ b/.config/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/.config/awesome/lain/layout/termfair.lua b/.config/awesome/lain/layout/termfair.lua new file mode 100644 index 0000000..89a44bb --- /dev/null +++ b/.config/awesome/lain/layout/termfair.lua @@ -0,0 +1,141 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (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 + + -- Screen. + local wa = p.workarea + local cls = p.clients + + -- 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 + else + g.width = width + end + if this_y == (num_y - 1) + then + g.height = wa.height - (num_y - 1) * height + else + g.height = height + end + + g.x = wa.x + this_x * width + g.y = wa.y + this_y * height + + 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. + + gap_factor = (useless_gap / 100) * 2 + + if this_x == 0 + then + g.width = g.width - (2 + gap_factor) * useless_gap + g.x = g.x + useless_gap + else + g.width = g.width - (1 + gap_factor) * useless_gap + end + + if this_y == 0 + then + g.height = g.height - (2 + gap_factor) * useless_gap + g.y = g.y + useless_gap + else + g.height = g.height - (1 + gap_factor) * useless_gap + end + 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/.config/awesome/lain/layout/uselessfair.lua b/.config/awesome/lain/layout/uselessfair.lua new file mode 100644 index 0000000..6aa6666 --- /dev/null +++ b/.config/awesome/lain/layout/uselessfair.lua @@ -0,0 +1,121 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (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 } +local tonumber = tonumber + +local uselessfair = {} + +local function fair(p, orientation) + -- 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 + + local wa = p.workarea + local cls = p.clients + + if #cls > 0 then + local cells = math.ceil(math.sqrt(#cls)) + local strips = math.ceil(#cls / cells) + + local cell = 0 + local strip = 0 + for k, c in ipairs(cls) do + local g = {} + -- Save actual grid index for use in the useless_gap + -- routine. + local this_x = 0 + local this_y = 0 + if ( orientation == "east" and #cls > 2 ) + or ( orientation == "south" and #cls <= 2 ) then + if #cls < (strips * cells) and strip == strips - 1 then + g.width = wa.width / (cells - ((strips * cells) - #cls)) + else + g.width = wa.width / cells + end + g.height = wa.height / strips + + this_x = cell + this_y = strip + + g.x = wa.x + cell * g.width + g.y = wa.y + strip * g.height + + else + if #cls < (strips * cells) and strip == strips - 1 then + g.height = wa.height / (cells - ((strips * cells) - #cls)) + else + g.height = wa.height / cells + end + g.width = wa.width / strips + + this_x = strip + this_y = cell + + g.x = wa.x + strip * g.width + g.y = wa.y + cell * g.height + end + + -- 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. + + gap_factor = (useless_gap / 100) * 2 + + if this_x == 0 + then + g.width = g.width - (2 + gap_factor) * useless_gap + g.x = g.x + useless_gap + else + g.width = g.width - (1 + gap_factor) * useless_gap + end + + if this_y == 0 + then + g.height = g.height - (2 + gap_factor) * useless_gap + g.y = g.y + useless_gap + else + g.height = g.height - (1 + gap_factor) * useless_gap + end + end + -- End of useless gap. + + c:geometry(g) + + cell = cell + 1 + if cell == cells then + cell = 0 + strip = strip + 1 + end + end + end +end + +--- Horizontal fair layout. +-- @param screen The screen to arrange. +uselessfair.horizontal = {} +uselessfair.horizontal.name = "uselessfairh" +function uselessfair.horizontal.arrange(p) + return fair(p, "east") +end + +-- Vertical fair layout. +-- @param screen The screen to arrange. +uselessfair.name = "uselessfair" +function uselessfair.arrange(p) + return fair(p, "south") +end + +return uselessfair diff --git a/.config/awesome/lain/layout/uselesspiral.lua b/.config/awesome/lain/layout/uselesspiral.lua new file mode 100644 index 0000000..3164c75 --- /dev/null +++ b/.config/awesome/lain/layout/uselesspiral.lua @@ -0,0 +1,110 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luke Bonham + * (c) 2009 Uli Schlachter + * (c) 2008 Julien Danjolu + +--]] + +local beautiful = require("beautiful") +local ipairs = ipairs +local tonumber = tonumber + +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 + + local wa = p.workarea + local cls = p.clients + local n = #cls + + 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 + wa2.y = wa.y + wa2.height = wa.height + wa2.width = wa.width + + -- 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 + + gap_factor = (useless_gap / 100) * 2 + + 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 - (2 + gap_factor) * useless_gap + wa2.y = wa2.y + useless_gap + else + wa2.height = wa2.height - (1 + gap_factor) * useless_gap + end + + if left then + wa2.width = wa2.width - (2 + gap_factor) * useless_gap + wa2.x = wa2.x + useless_gap + else + wa2.width = wa2.width - (1 + gap_factor) * useless_gap + 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/.config/awesome/lain/layout/uselesstile.lua b/.config/awesome/lain/layout/uselesstile.lua new file mode 100644 index 0000000..e496500 --- /dev/null +++ b/.config/awesome/lain/layout/uselesstile.lua @@ -0,0 +1,230 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (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, + max = math.max, + min = math.min } +local tonumber = tonumber + +local uselesstile = {} + +local function tile_group(cls, wa, orientation, fact, group) + -- 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 + + -- get our orientation right + local height = "height" + local width = "width" + local x = "x" + local y = "y" + if orientation == "top" or orientation == "bottom" then + height = "width" + width = "height" + x = "y" + y = "x" + end + + -- make this more generic (not just width) + available = wa[width] - (group.coord - wa[x]) + + -- find our total values + local total_fact = 0 + local min_fact = 1 + local size = group.size + for c = group.first,group.last do + -- determine the width/height based on the size_hint + local i = c - group.first +1 + local size_hints = cls[c].size_hints + local size_hint = size_hints["min_"..width] or size_hints["base_"..width] or 0 + size_hint = size_hint + cls[c].border_width*2 + size = math.max(size_hint, size) + + -- calculate the height + if not fact[i] then + fact[i] = min_fact + else + min_fact = math.min(fact[i],min_fact) + end + total_fact = total_fact + fact[i] + end + size = math.min(size, available) + + local coord = wa[y] + local geom = {} + local used_size = 0 + local unused = wa[height] + local stat_coord = wa[x] + --stat_coord = size + for c = group.first,group.last do + local i = c - group.first +1 + geom[width] = size + geom[height] = math.floor(unused * fact[i] / total_fact) + geom[x] = group.coord + geom[y] = coord + + coord = coord + geom[height] + unused = unused - geom[height] + total_fact = total_fact - fact[i] + used_size = math.max(used_size, geom[width]) + + -- 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 + + gap_factor = (useless_gap / 100) * 2 + + if geom[y] == wa[y] then + top = true + end + + if geom[x] == 0 or geom[x] == wa[x] then + left = true + end + + if top then + geom[height] = geom[height] - (2 + gap_factor) * useless_gap + geom[y] = geom[y] + useless_gap + else + geom[height] = geom[height] - (1 + gap_factor) * useless_gap + end + + if left then + geom[width] = geom[width] - (2 + gap_factor) * useless_gap + geom[x] = geom[x] + useless_gap + else + geom[width] = geom[width] - (1 + gap_factor) * useless_gap + end + end + -- End of useless gap. + + geom = cls[c]:geometry(geom) + end + + return used_size +end + +local function tile(param, orientation) + local t = tag.selected(param.screen) + orientation = orientation or "right" + + -- this handles are different orientations + local height = "height" + local width = "width" + local x = "x" + local y = "y" + if orientation == "top" or orientation == "bottom" then + height = "width" + width = "height" + x = "y" + y = "x" + end + + local cls = param.clients + local nmaster = math.min(tag.getnmaster(t), #cls) + local nother = math.max(#cls - nmaster,0) + + local mwfact = tag.getmwfact(t) + local wa = param.workarea + local ncol = tag.getncol(t) + + local data = tag.getdata(t).windowfact + + if not data then + data = {} + tag.getdata(t).windowfact = data + end + + local coord = wa[x] + local place_master = true + if orientation == "left" or orientation == "top" then + -- if we are on the left or top we need to render the other windows first + place_master = false + end + + -- this was easier than writing functions because there is a lot of data we need + for d = 1,2 do + if place_master and nmaster > 0 then + local size = wa[width] + if nother > 0 then + size = math.min(wa[width] * mwfact, wa[width] - (coord - wa[x])) + end + if not data[0] then + data[0] = {} + end + coord = coord + tile_group(cls, wa, orientation, data[0], {first=1, last=nmaster, coord = coord, size = size}) + end + + if not place_master and nother > 0 then + local last = nmaster + + -- we have to modify the work area size to consider left and top views + local wasize = wa[width] + if nmaster > 0 and (orientation == "left" or orientation == "top") then + wasize = wa[width] - wa[width]*mwfact + end + for i = 1,ncol do + -- Try to get equal width among remaining columns + local size = math.min( (wasize - (coord - wa[x])) / (ncol - i + 1) ) + local first = last + 1 + last = last + math.floor((#cls - last)/(ncol - i + 1)) + -- tile the column and update our current x coordinate + if not data[i] then + data[i] = {} + end + coord = coord + tile_group(cls, wa, orientation, data[i], { first = first, last = last, coord = coord, size = size }) + end + end + place_master = not place_master + end + +end + +uselesstile.right = {} +uselesstile.right.name = "uselesstile" +uselesstile.right.arrange = tile + +--- The main tile algo, on left. +-- @param screen The screen number to tile. +uselesstile.left = {} +uselesstile.left.name = "uselesstileleft" +function uselesstile.left.arrange(p) + return tile(p, "left") +end + +--- The main tile algo, on bottom. +-- @param screen The screen number to tile. +uselesstile.bottom = {} +uselesstile.bottom.name = "uselesstilebottom" +function uselesstile.bottom.arrange(p) + return tile(p, "bottom") +end + +--- The main tile algo, on top. +-- @param screen The screen number to tile. +uselesstile.top = {} +uselesstile.top.name = "uselesstiletop" +function uselesstile.top.arrange(p) + return tile(p, "top") +end + +uselesstile.arrange = uselesstile.right.arrange +uselesstile.name = uselesstile.right.name + +return uselesstile |