You are not logged in.

#1 2011-10-18 17:57:53

phoric
Member
From: Seattle, WA
Registered: 2011-10-17
Posts: 27

Awesome WM - remember floating window sizes & positions?

Been using Awesome for a few weeks now (well, a few months, but haven't dug too deep into learning rc.lua and customizing it much until recently).

It is, well, awesome, but I have one lingering question: Is it possible to have Awesome remember/restore the sizes and positions of my floating windows -- say, after cycling through the tiling layouts with Mod4-Spacebar? I'd prefer not have to manually resize all of my windows every time I decide to use a floating layout for some programs or on one of my tags.

I realize it is a tiling window manager, and thus I have a feeling what the answer will be, since I can't seem to find anything on this. So no biggie, but I am still curious.

Offline

#2 2012-05-25 10:38:32

NewWorld
Member
Registered: 2010-02-15
Posts: 33

Re: Awesome WM - remember floating window sizes & positions?

Yes I'm sure there is a way to script this if you get familiar with the API. Fundamentally, it could go something like this:

function storeFloats:
1) Get all clients (windows) of current tag (workspace)
2) Filter all clients that have property "floating = true"
3) Store the client ID, geometry, screen position and properties (maximised, sticky, etc.) of each of these floating clients in some variables

function restoreFloats:
1) Restore the settings for each floating client from the stored variables

Then either somehow integrate these into your "change layout" keybind or figure out how to do it with signals, so that it knows to call storeFloats() when layout is changed from "Floating" to any other layout (the rest are tiling by default); and call restoreFloats() when you switch from "tiling" to "floating" layout.

If there's an easier way, I don't know it - but I'm new to awesomeWM, myself.

Offline

#3 2012-05-25 14:08:19

Wibjarm
Member
Registered: 2012-05-04
Posts: 43

Re: Awesome WM - remember floating window sizes & positions?

One config file snippet, coming right up!

floatgeoms = {}

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(floatgeoms[c.window])
        end
    endclient.connect_signal("unmanage", function(c) floatgeoms[c.window] = nil end)
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
        floatgeoms[c.window] = c:geometry()
    end
end)

client.connect_signal("unmanage", function(c) floatgeoms[c.window] = nil 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
        floatgeoms[c.window] = c:geometry()
    end
end)

Not all that well tested, but it /should/ work, and the unmanage function should keep the table of geometries from growing like crazy by deleting each window's stored geometry as it gets killed rather than just leaving them sitting around forever.

Edit:  Remembered that you can have multiple functions hooked up to one signal, so this can just be copypasted straight into your rc.lua and it should Just Work.

Last edited by Wibjarm (2012-05-25 14:49:04)

Offline

Board footer

Powered by FluxBB