Search code examples
luawindow-managersawesome-wm

Different background color for each taglist item AwesomeWM


how can I set a different background color for each taglist item? I know I have to use widget_template but I don't know how, I'm on awesomeWM 4.3


Solution

  • Suppose you have tags named with keys of this colors table:

    colors = {
       term = "#FF0000",
       www = "#00FF00",
       divers = "#0000FF",
       travail = "#FF0000",
       default = "#00FF00"
    }
    

    and maybe some others.

    With widget_template, (you've cited), within awful.widget.taglist:

    widget_template = {
           {
              id     = 'text_role',
              widget = wibox.widget.textbox
            },
            id     = 'bg',
            widget = wibox.container.background,
            create_callback = function(self, t, index, tagsList)
               self.bg = colors[t.name] or colors.default
            end,
        }
    

    enter image description here

    See also: documentation