Create custom layout
This commit is contained in:
parent
52d8678aac
commit
6fedd71ed2
|
@ -380,7 +380,7 @@ keys.globalkeys = gears.table.join(
|
|||
-- Focus screen by index (cycle through screens)
|
||||
awful.key({modkey}, "s",
|
||||
function()
|
||||
awful.screen.focus_relative(1)
|
||||
awful.screen.focus_relative(-1)
|
||||
end
|
||||
),
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c489aa63acc1364851e0e51152be3db5c75e145d
|
||||
Subproject commit 88f5a8abd2649b348ffec433a24a263b37f122c0
|
|
@ -0,0 +1,109 @@
|
|||
-- Grab environment we need
|
||||
local ipairs = ipairs
|
||||
local math = math
|
||||
|
||||
--- The gridh layout layoutbox icon.
|
||||
-- @beautiful beautiful.layout_gridh
|
||||
-- @param surface
|
||||
-- @see gears.surface
|
||||
|
||||
--- The gridv layout layoutbox icon.
|
||||
-- @beautiful beautiful.layout_gridv
|
||||
-- @param surface
|
||||
-- @see gears.surface
|
||||
|
||||
local grid = {}
|
||||
|
||||
local function do_grid(p, orientation)
|
||||
local wa = p.workarea
|
||||
local cls = p.clients
|
||||
|
||||
-- Swap workarea dimensions, if our orientation is "east"
|
||||
if orientation == 'east' then
|
||||
wa.width, wa.height = wa.height, wa.width
|
||||
wa.x, wa.y = wa.y, wa.x
|
||||
end
|
||||
|
||||
if #cls > 0 then
|
||||
local rows, cols
|
||||
if #cls == 2 then
|
||||
rows, cols = 1, 2
|
||||
else
|
||||
rows = math.ceil(math.sqrt(#cls))
|
||||
cols = math.ceil(#cls / rows)
|
||||
end
|
||||
local first_col_rows = #cls - rows * (cols - 1)
|
||||
for k, c in ipairs(cls) do
|
||||
k = k - 1
|
||||
local g = {}
|
||||
|
||||
local row, col, lrows, lcols
|
||||
if k < first_col_rows then
|
||||
row = k
|
||||
col = 0
|
||||
lrows = first_col_rows
|
||||
lcols = cols
|
||||
else
|
||||
row = (k - first_col_rows) % rows
|
||||
col = math.floor((k - first_col_rows) / rows) + 1
|
||||
lrows = rows
|
||||
lcols = cols
|
||||
end
|
||||
|
||||
if row == lrows - 1 then
|
||||
g.height = wa.height - math.ceil(wa.height / lrows) * row
|
||||
g.y = wa.height - g.height
|
||||
else
|
||||
g.height = math.ceil(wa.height / lrows)
|
||||
g.y = g.height * row
|
||||
end
|
||||
|
||||
if col == lcols - 1 then
|
||||
g.width = wa.width - math.ceil(wa.width / lcols) * col
|
||||
g.x = wa.width - g.width
|
||||
else
|
||||
g.width = math.ceil(wa.width / lcols)
|
||||
g.x = g.width * col
|
||||
end
|
||||
|
||||
g.y = g.y + wa.y
|
||||
g.x = g.x + wa.x
|
||||
|
||||
-- Swap window dimensions, if our orientation is "east"
|
||||
if orientation == 'east' then
|
||||
g.width, g.height = g.height, g.width
|
||||
g.x, g.y = g.y, g.x
|
||||
end
|
||||
|
||||
p.geometries[c] = g
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Horizontal grid layout.
|
||||
-- @param screen The screen to arrange.
|
||||
grid.horizontal = {}
|
||||
grid.horizontal.name = "gridh"
|
||||
|
||||
function grid.horizontal.arrange(p)
|
||||
return do_grid(p, "east")
|
||||
end
|
||||
|
||||
-- Vertical grid layout.
|
||||
-- @param screen The screen to arrange.
|
||||
grid.name = "grid"
|
||||
function grid.arrange(p)
|
||||
return do_grid(p, "south")
|
||||
end
|
||||
|
||||
--- The grid layout.
|
||||
-- Try to give all clients the same size.
|
||||
-- @clientlayout awful.layout.suit.grid
|
||||
-- @usebeautiful beautiful.layout_gridv
|
||||
|
||||
--- The horizontal grid layout.
|
||||
-- Try to give all clients the same size.
|
||||
-- @clientlayout awful.layout.suit.grid.horizontal
|
||||
-- @usebeautiful beautiful.layout_gridh
|
||||
|
||||
return grid
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
local awful = require("awful")
|
||||
local lain = require("lain")
|
||||
local grid = require("layout.grid")
|
||||
local quake = lain.util.quake({app="alacritty", followtag=true, argname = '--class %s', extra="--option=window.opacity=1.0 --option=\"colors.primary.background='#000d2b'\" -e tmux", height=0.3})
|
||||
|
||||
local pastel = {}
|
||||
|
@ -34,7 +35,7 @@ pastel.initialize = function()
|
|||
for i = 1, 9, 1
|
||||
do
|
||||
awful.tag.add(tostring(i), {
|
||||
layout = awful.layout.suit.tile,
|
||||
layout = grid,
|
||||
screen = s,
|
||||
selected = i == 1
|
||||
})
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
-- Standard awesome libraries
|
||||
local gears = require("gears")
|
||||
local awful = require("awful")
|
||||
local grid = require("layout.grid")
|
||||
|
||||
|
||||
-- ===================================================================
|
||||
|
@ -36,6 +37,18 @@ local run_on_start_up = {
|
|||
-- Initialization
|
||||
-- ===================================================================
|
||||
|
||||
-- Define layouts
|
||||
awful.layout.layouts = {
|
||||
grid,
|
||||
awful.layout.suit.tile,
|
||||
awful.layout.suit.floating,
|
||||
grid.horizontal,
|
||||
awful.layout.suit.fair.horizontal,
|
||||
awful.layout.suit.tile.left,
|
||||
awful.layout.suit.tile.bottom,
|
||||
awful.layout.suit.tile.top,
|
||||
}
|
||||
|
||||
|
||||
-- Import notification appearance
|
||||
require("components.notifications")
|
||||
|
@ -68,17 +81,6 @@ root.buttons(keys.desktopbuttons)
|
|||
local create_rules = require("rules").create
|
||||
awful.rules.rules = create_rules(keys.clientkeys, keys.clientbuttons)
|
||||
|
||||
-- Define layouts
|
||||
awful.layout.layouts = {
|
||||
awful.layout.suit.tile,
|
||||
awful.layout.suit.floating,
|
||||
awful.layout.suit.fair,
|
||||
awful.layout.suit.fair.horizontal,
|
||||
awful.layout.suit.tile.left,
|
||||
awful.layout.suit.tile.bottom,
|
||||
awful.layout.suit.tile.top,
|
||||
}
|
||||
|
||||
-- ===================================================================
|
||||
-- Client Focusing
|
||||
-- ===================================================================
|
||||
|
|
Loading…
Reference in New Issue