rainbow: new uselessgaps layouts
This commit is contained in:
parent
0537a8c233
commit
06d802d773
|
@ -0,0 +1,110 @@
|
|||
---------------------------------------------------------------------------
|
||||
-- @author Julien Danjou <julien@danjou.info>
|
||||
-- @copyright 2008 Julien Danjou
|
||||
-- @release v3.4.11
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
-- Grab environment we need
|
||||
local ipairs = ipairs
|
||||
local math = math
|
||||
|
||||
module("layouts.fairgaps")
|
||||
|
||||
local function fair(p, orientation)
|
||||
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 = {}
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
g.x = wa.x + strip * g.width
|
||||
g.y = wa.y + cell * g.height
|
||||
end
|
||||
|
||||
-- Useless gap.
|
||||
useless_gap = 25
|
||||
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 g.x == wa.x then
|
||||
top = true
|
||||
end
|
||||
|
||||
if g.y == wa.y then
|
||||
left = true
|
||||
end
|
||||
|
||||
if top then
|
||||
g.width = g.width - 2 * useless_gap
|
||||
g.x = g.x + useless_gap
|
||||
else
|
||||
g.width = g.width - useless_gap
|
||||
end
|
||||
|
||||
if left then
|
||||
g.height = g.height - 2 * useless_gap
|
||||
g.y = g.y + useless_gap
|
||||
else
|
||||
g.height = g.height - 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.
|
||||
horizontal = {}
|
||||
horizontal.name = "fairhgaps"
|
||||
function horizontal.arrange(p)
|
||||
return fair(p, "east")
|
||||
end
|
||||
|
||||
-- Vertical fair layout.
|
||||
-- @param screen The screen to arrange.
|
||||
name = "fairvgaps"
|
||||
function arrange(p)
|
||||
return fair(p, "south")
|
||||
end
|
|
@ -1,3 +1,5 @@
|
|||
require("layouts.fairgaps")
|
||||
require("layouts.spiralgaps")
|
||||
require("layouts.tilegaps")
|
||||
|
||||
module("layouts")
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
---------------------------------------------------------------------------
|
||||
-- @author Uli Schlachter <psychon@znc.in>
|
||||
-- @copyright 2009 Uli Schlachter
|
||||
-- @copyright 2008 Julien Danjou
|
||||
-- @release v3.4.11
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
-- Grab environment we need
|
||||
local ipairs = ipairs
|
||||
|
||||
module("layouts.spiralgaps")
|
||||
|
||||
local function spiral(p, spiral)
|
||||
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.
|
||||
useless_gap = 25
|
||||
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 - 2 * useless_gap
|
||||
wa2.y = wa2.y + useless_gap
|
||||
else
|
||||
wa2.height = wa2.height - useless_gap
|
||||
end
|
||||
|
||||
if left then
|
||||
wa2.width = wa2.width - 2 * useless_gap
|
||||
wa2.x = wa2.x + useless_gap
|
||||
else
|
||||
wa2.width = wa2.width - useless_gap
|
||||
end
|
||||
end
|
||||
-- End of useless gap.
|
||||
|
||||
c:geometry(wa2)
|
||||
end
|
||||
end
|
||||
|
||||
--- Dwindle layout
|
||||
dwindle = {}
|
||||
dwindle.name = "dwindlegaps"
|
||||
function dwindle.arrange(p)
|
||||
return spiral(p, false)
|
||||
end
|
||||
|
||||
--- Spiral layout
|
||||
name = "spiralgaps"
|
||||
function arrange(p)
|
||||
return spiral(p, true)
|
||||
end
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -195,7 +195,7 @@ right.arrange = tile
|
|||
--- The main tile algo, on left.
|
||||
-- @param screen The screen number to tile.
|
||||
left = {}
|
||||
left.name = "tilegapsleft"
|
||||
left.name = "tileleftgaps"
|
||||
function left.arrange(p)
|
||||
return tile(p, "left")
|
||||
end
|
||||
|
@ -203,7 +203,7 @@ end
|
|||
--- The main tile algo, on bottom.
|
||||
-- @param screen The screen number to tile.
|
||||
bottom = {}
|
||||
bottom.name = "tilegapsbottom"
|
||||
bottom.name = "tilebottomgaps"
|
||||
function bottom.arrange(p)
|
||||
return tile(p, "bottom")
|
||||
end
|
||||
|
@ -211,7 +211,7 @@ end
|
|||
--- The main tile algo, on top.
|
||||
-- @param screen The screen number to tile.
|
||||
top = {}
|
||||
top.name = "tilegapstop"
|
||||
top.name = "tiletopgaps"
|
||||
function top.arrange(p)
|
||||
return tile(p, "top")
|
||||
end
|
||||
|
|
|
@ -84,7 +84,7 @@ language = string.gsub(os.getenv("LANG"), ".utf8", "")
|
|||
beautiful.init(active_theme .. "/theme.lua")
|
||||
|
||||
terminal = "urxvtc"
|
||||
editor = os.getenv("EDITOR") or "vim"
|
||||
editor = os.getenv("EDITOR")
|
||||
editor_cmd = terminal .. " -e " .. editor
|
||||
gui_editor = "gvim"
|
||||
browser = "dwb"
|
||||
|
@ -186,7 +186,7 @@ clockwidget:set_widget(mytextclock)
|
|||
clockwidget:set_bgimage(beautiful.widget_bg)
|
||||
|
||||
-- Calendar widget
|
||||
mytextcalendar = awful.widget.textclock(white .. space .. "%d %B<span font='Tamsyn 5'> </span>" .. coldef)
|
||||
mytextcalendar = awful.widget.textclock(white .. space .. "%A %d %B<span font='Tamsyn 5'> </span>" .. coldef)
|
||||
calendar_icon = wibox.widget.imagebox()
|
||||
calendar_icon:set_image(beautiful.calendar)
|
||||
calendarwidget = wibox.widget.background()
|
||||
|
|
|
@ -103,7 +103,9 @@ layouts =
|
|||
awful.layout.suit.fair, -- 3
|
||||
awful.layout.suit.tile.bottom, -- 4
|
||||
awful.layout.suit.fair.horizontal, -- 5
|
||||
layouts.tilegaps, -- 6
|
||||
layouts.tilegaps, -- 6
|
||||
layouts.fairgaps, -- 7
|
||||
layouts.spiralgaps, -- 8
|
||||
}
|
||||
|
||||
-- }}}
|
||||
|
|
|
@ -33,7 +33,6 @@ theme.widget_mail_notify = themes_dir .. "/icons/mail_notify.
|
|||
theme.widget_no_net_notify = themes_dir .. "/icons/no_net_notify.png"
|
||||
|
||||
theme.layout_txt_tile = "[t]"
|
||||
theme.layout_txt_tilegaps = "[t2]"
|
||||
theme.layout_txt_tileleft = "[l]"
|
||||
theme.layout_txt_tilebottom = "[b]"
|
||||
theme.layout_txt_tiletop = "[tt]"
|
||||
|
@ -46,6 +45,10 @@ theme.layout_txt_fullscreen = "[F]"
|
|||
theme.layout_txt_magnifier = "[M]"
|
||||
theme.layout_txt_floating = "[*]"
|
||||
|
||||
theme.layout_txt_tilegaps = "[tg]"
|
||||
theme.layout_txt_fairvgaps = "[fvg]"
|
||||
theme.layout_txt_spiralgaps = "[sg]"
|
||||
|
||||
theme.tasklist_floating = ""
|
||||
theme.tasklist_maximized_horizontal = ""
|
||||
theme.tasklist_maximized_vertical = ""
|
||||
|
|
Loading…
Reference in New Issue