From 7f68f9c9f5620a964310cb618a0db98d66919159 Mon Sep 17 00:00:00 2001 From: Von Random Date: Thu, 19 Mar 2015 19:47:20 +0300 Subject: [PATCH] a new cool feature for awesome: save window sizes and positions to restore them when going back to floating --- rc.lua | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/rc.lua b/rc.lua index 6983674..adc3ea6 100644 --- a/rc.lua +++ b/rc.lua @@ -140,7 +140,7 @@ tags = {} saved_layouts = {} for s = 1, screen.count() do tags[s] = { name = {}, layout = {} } - saved_layouts[s] = { tiled = {} } + saved_layouts[s] = { tiled = {}, float = {} } end -- screen 1 --tags[1].name = { @@ -701,6 +701,47 @@ client.connect_signal( client.connect_signal('focus', function(c) c.border_color = beautiful.border_focus end) client.connect_signal('unfocus', function(c) c.border_color = beautiful.border_normal end) + +-- save floating layout parameters for windows created and managed during the current session +tag.connect_signal( + 'property::layout', + function(t) + for k, c in ipairs(t:clients()) do + if awful.layout.get(mouse.screen) == awful.layout.suit.floating or awful.client.floating.get(c) == true then + c:geometry(saved_layouts[c.screen].float[c.window]) + end + end + end +) + +client.connect_signal( + 'manage', + function(c) + if awful.layout.get(mouse.screen) == awful.layout.suit.floating or awful.client.floating.get(c) == true then + saved_layouts[c.screen].float[c.window] = c:geometry() + end + end +) + +client.connect_signal('unmanage', function(c) saved_layouts[c.screen].float[c.window] = nil end) + +client.connect_signal( + 'property::geometry', + function(c) + if awful.layout.get(mouse.screen) == awful.layout.suit.floating or awful.client.floating.get(c) == true then + saved_layouts[c.screen].float[c.window] = c:geometry() + end + end +) + +client.connect_signal( + 'property::floating', + function(c) + if awful.client.floating.get(c) == true and saved_layouts[c.screen].float[c.window] ~= nil then + c:geometry(saved_layouts[c.screen].float[c.window]) + end + end +) -- }}} -- {{{ Autostart -- don't forget you sync this file