Skip to content

Instantly share code, notes, and snippets.

@appuchias
Created June 30, 2022 01:31
Show Gist options
  • Save appuchias/7887dbd019ac4d4f3ddda276ff4f4e99 to your computer and use it in GitHub Desktop.
Save appuchias/7887dbd019ac4d4f3ddda276ff4f4e99 to your computer and use it in GitHub Desktop.
Center AwesomeWM floating windows when created and toggled.
-- This file includes both changes that need to be made, but they likely won't be placed like this in your files.
-- You will need to find the place to include those lines. You can ask me if you can't figure it out.
-- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- Key to toggle between floating and tiled
clientkeys = gears.table.join( -- Find by this line
awful.key({modkey, "Control"}, "space", function(c) -- Center and raise floating windows if there is more than one
awful.client.floating.toggle(c)
local num_tiled_clients = 0
for _ in pairs(c.screen.tiled_clients) do num_tiled_clients = num_tiled_clients + 1 end
if num_tiled_clients >= 1 then
awful.placement.centered(c, nil)
end
c:raise()
end,
{
description = "Toggle floating",
group = "client"
}
),
)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- This way you set the default behaviour
awful.rules.rules = {{ -- All clients will match this rule.
rule = {},
properties = {
border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
keys = clientkeys,
buttons = clientbuttons,
screen = awful.screen.preferred,
titlebars_enabled = false,
placement = awful.placement.centered + awful.placement.no_overlap + awful.placement.no_offscreen -- This is the important line
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment