Output of awesome --version:
~ $ awesome --version
awesome v4.2 (Human after all)
• Compiled against Lua 5.3.4 (running with Lua 5.3)
• D-Bus support: ✔
• execinfo support: ✔
• xcb-randr version: 1.5
• LGI version: 0.9.2
This is more like a question than issue. I'm trying to force fixed size of floating application window (feh in my case). This image viewer is specific, because it changes window size depending on resolution of currently displayed image. If you open a few images with different resolutions then window will change its size when switching images.
So, i'm trying to set fixed size of floating window. Here is my awfulnaive rule:
{
rule = { class = 'feh' },
properties = {
floating = true,
placement = awful.placement.centered,
width = awful.screen.focused().workarea.width * 0.8,
height = awful.screen.focused().workarea.height * 0.8
}
}
It somewhat _works_. By _works_ I mean window is really centered and have proper size, but for first image only.
I think it may be achieved by using awful.placement.centered() function, but I can't figure out how to use it. What is this args argument? This seems to be completely undocumented.
Rules are only applied on startup, so this is expected behaviour (from Awesome's point of view). You could use signals to do that, but that might interfere with / restrict manual resizing (consider @psychon's comment). A much simpler way, in this case, would be to configure feh to have a fixed size, like this for example - also consider man feh for this.
So... awful.rules-rules are only applied when the window first becomes visible. You want something that also works during runtime.
Try this (outside of the rules, in some global context):
-- Disconnect the default handler for resizie requests
client.disconnect_signal("request::geometry", awful.ewmh.client_geometry_requests)
-- Connect our own handler
client.connect_signal("request::geometry", function(c, ...)
if c.class ~= "feh" then
awful.ewmh.client_geometry_requests(c, ...)
end
end)
@maln0ir ping? Did that help you?
Yes, that helped. At first I just wanted to use solution proposed by @alfunx because I had hard time understanding how signals work and what exactly are hints, but after some digging I made this:
client.disconnect_signal("request::geometry", awful.ewmh.client_geometry_requests)
client.connect_signal("request::geometry", function(c, context, hints)
if c.class == "feh" then
workarea = awful.screen.focused().workarea
hints = awful.placement.centered(c)
hints.width = workarea.width * beautiful.feh_scale
hints.height = workarea.height * beautiful.feh_scale
end
awful.ewmh.client_geometry_requests(c, context, hints)
end)
I can even change scale at runtime, but there is some minor issue: window changes its size and position in two steps instead of one. I have no idea why this happens, but I can live with that :shrug:
Solved.
PS. Oh, markdown in emails not supported...
Most helpful comment
So...
awful.rules-rules are only applied when the window first becomes visible. You want something that also works during runtime.Try this (outside of the rules, in some global context):