I have three monitors in a horizontal line. Sometimes i want to maximize a window to three monitors at once, by pressing a combination of keys (and then returning it all back if necessary). How can I do that?
Asked
Active
Viewed 860 times
1 Answers
2
Untested, but the basic idea is to make the window floating and resize it to cover everything:
function(c)
c.floating = true
local geo = screen[1].geometry
geo.x2 = geo.x + geo.width
geo.y2 = geo.y + geo.height
for s in screen do
local geo2 = s.geometry
geo.x = math.min(geo.x, geo2.x)
geo.y = math.min(geo.y, geo2.y)
geo.x2 = math.max(geo.x2, geo2.x + geo2.width)
geo.y2 = math.max(geo.y2, geo2.y + geo2.height)
end
c:geometry{
x = geo.x,
y = geo.y,
width = geo.x2 - geo.x,
height = geo.y2 - geo.y
}
end
To undo the above, make the client no longer floating, i.e. c.floating = false
.
Wiring the above to a keybinding is left as an exercise for the reader.

Uli Schlachter
- 9,337
- 1
- 23
- 39
-
Working. But screen.geometry instead screen:geometry(). Thanks! – Sheridan Feb 16 '18 at 10:09
-
1Whoops, sorry. Updated. – Uli Schlachter Feb 17 '18 at 11:27
-
The code seems to change screen[1].geometry unintentionally. I've tried to fix it: https://gist.github.com/majecty/937ff61ccdc1ea24759d36706dc45454 – juhyung park Jan 16 '23 at 07:37