Search code examples
luaborderawesome-wm

How do I disable the window border in theme.lua/rc.lua (AwesomeWM)


I am trying to edit my .config/awesome/theme.lua and .config/theme/rc.lua files for AwesomeWM. I have the following lines in the theme.lua file:

theme.border_width = dpi(5)
theme.border_normal = "#14ff1b"
theme.border_focus = "#00158f"

Which works perfectly well - limey-green border on inactive window(s) and blue border on the active window. The issue is that I also am running polybar (after removing the rc.lua lines for the default bar) and am launching it like this in the rc.lua (it is out-of-place when I launch it from the .xinitrc after an AwesomeWM reload):

awful.spawn.with_shell("killall -q polybar") -- necesarry for a reload
awful.spawn.with_shell("polybar mybar") -- mybar is the name of the bar in `.config/polybar/config`

This permanently gives me an obnoxious green border around polybar, and my issue is that I want to remove that. I tried putting this in rc.lua before the above lines:

ruled.client.append_rule {
    rule = { class = "polybar" },
    properties = { client.border_width = 0 }
}

but this doesn't work. I looked around on Reddit and the AwesomeWM documentation, but this is the best that I could come up with, and it doesn't work. Does anyone know how I can do this, if I can even do this (remove the obnoxious 5dp border from Polybar, while keeping it on basically everything else).

Also, I tried changing it to client.border_width = xresources.apply_dpi(0), because the default theme.lua file sets dpi() as xresources.apply_dpi() and sets the border width to dpi(2) (which I changed to 5), but that didn't work either.

Update 1: I posted this on reddit, and after responses and more documentation reading I wrote this, which still doesn't work:

{ rule = { class = "Polybar" },
    properties = { border_width = 0 } }

I tried replacing "class" with "instance" and "name" (not rly sure hat the difference is), and I tried using both capitalized "Polybar" and lowercase "polybar", but those didn't work.


Solution

  • Ok, so I figured this out. I asked on a reddit post, and I got two pieces of useful information from that:

    • Since I don't use nightly, I cannot use ruled., and rather must use awful.rules.
    • "Polybar" may work while "polybar" may not.

    So for the solution:

    At one point in the rc.lua, you get the following:

    awful.rules.rules = {
        { 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,
                         placement = awful.placement.no_overlap+awful.placement.no_offscreen
          }
        }
        ...
    

    So, that sets a bunch of stuff for all apps. I then commented out this part of this line:

          properties = { -- border_width = beautiful.border_width,
    

    This then removed the border width and therefore the border. I then below that added a separate part that adds the border width to everything except polybar:

        { rule = { },
          except_any = { class = { "Polybar" } },
          properties = { border_width = beautiful.border_width }
        },
    

    In case I want to remove the border from anything else in the future, I can do it like this:

    except_any = { class = { "Polybar", "OtherApp1", "OtherApp2", "OtherApp3" } },