Last active
June 6, 2020 12:28
-
-
Save shimarin/ce86464c622ab41ceacb76169af45802 to your computer and use it in GitHub Desktop.
Custom layout for Awesome WM with triple vertical screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local math = math | |
local horiz3 = { | |
name = "horiz3" | |
} | |
function split_horizontal(g) | |
g.width = g.width / 2 | |
return { | |
x = g.x + g.width, | |
y = g.y, | |
width = g.width, | |
height = g.height, | |
} | |
end | |
function split_vertical(g) | |
g.height = g.height / 2 | |
return { | |
x = g.x, | |
y = g.y + g.height, | |
width = g.width, | |
height = g.height, | |
} | |
end | |
function split_2to3(g1, g2) | |
g1.height = g1.height * 2 / 3 | |
g2.height = g2.height * 2 / 3 | |
g2.y = g1.y + g1.height | |
return { | |
x = g1.x, | |
y = g2.y + g2.height, | |
width = g1.width, | |
height = g1.height, | |
} | |
end | |
function horiz3.arrange(p) | |
local wa = p.workarea | |
local cls = p.clients | |
if #cls > 0 then | |
p.geometries[cls[1]] = { | |
x = wa.x, | |
y = wa.y, | |
width = wa.width, | |
height = wa.height | |
} | |
if #cls >= 2 then | |
p.geometries[cls[1]].width = wa.width / 3 | |
p.geometries[cls[2]] = { | |
x = wa.x + wa.width / 3, | |
y = wa.y, | |
width = wa.width * 2 / 3, | |
height = wa.height | |
} | |
end | |
if #cls >= 3 then | |
p.geometries[cls[3]] = split_horizontal(p.geometries[cls[2]]) | |
end | |
if #cls >= 4 then | |
for i = 4,math.min(#cls,6) do | |
p.geometries[cls[i]] = split_vertical(p.geometries[cls[i - 3]]) | |
end | |
end | |
if #cls >= 7 then | |
for i = 7,math.min(#cls,12) do | |
p.geometries[cls[i]] = split_horizontal(p.geometries[cls[i - 6]]) | |
end | |
end | |
if #cls >= 13 then | |
if #cls <= 18 then | |
local map = { 1, 7, 2, 8, 3, 9 } | |
for i = 13,#cls do | |
p.geometries[cls[i]] = split_2to3(p.geometries[cls[map[i - 12]]], p.geometries[cls[map[i - 12]+3]]) | |
end | |
else | |
local base = 12 | |
for i = 13,#cls do | |
if i > base * 2 then | |
base = base * 2 | |
end | |
p.geometries[cls[i]] = split_vertical(p.geometries[cls[i - base]]) | |
end | |
end | |
end | |
end | |
end | |
return horiz3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment