Search code examples
pythonlinuxconfigarchlinuxwindow-managers

config error in Qtile (Tiling Window Manager)


im trying to configure qtile by looking at a reference config from DistroTube(Youtube)'s gitlab : https://gitlab.com/dwt1/dotfiles/-/blob/master/.config/qtile/config.py

im getting an error while adding this

##### BAR #####

def init_widgets_screen():
widgets_screen = init_widgets_list()
return widgets_screen

def init_screens() :
return [Screen(top=bar.Bar(widgets=init_widgets_screen(), opacity=0.95, size=20))

if __name__ in ["config", "__main__"]:
screens = init_screens()
widgets_list = init_widgets_list()
widget_screen = init_widgets_screen()

he is using 3 monitors, and im trying to install this on my laptop so just one screen

( the needed part in the reference link starts on line 555)


Solution

  • It looks like it might just be a white spacing issue. You need to indent each function body. There's also an extra white space before the colon in the init_screens definition (though I think this is actually legal python).

    In the case that the lack of indenting was just from copy and pasting into stack overflow, it would help if you could run qtile in a terminal and copy the output/error here.

    ##### BAR #####
    
    def init_widgets_screen():
        widgets_screen = init_widgets_list()
        return widgets_screen
    
    def init_screens():
        return [Screen(top=bar.Bar(widgets=init_widgets_screen(), opacity=0.95, size=20))
    
    if __name__ in ["config", "__main__"]:
        screens = init_screens()
        widgets_list = init_widgets_list()
        widget_screen = init_widgets_screen()
    

    Edit after clarification

    Your config file has defines the init_widgets_list function between line 114 and 317 and it looks something like this:

    def init_widgets_list():
      widgets_list = [
        [
          widget.Sep(
            linewidth = 0,
            padding = 6,
            foreground = colors[2],
            background = colors[0]
          ),
          # ...
          widget.Systray(
            background=colors[0],
            padding = 5
          ),
        ],
      ]
    
      return widgets_list
    

    You are wrapping the list of widgets in another list and qtile is expecting a flat list of widgets. To fix it you need to remove one set of square brackets.

    def init_widgets_list():
      widgets_list = [
        widget.Sep(
          linewidth = 0,
          padding = 6,
          foreground = colors[2],
          background = colors[0]
        ),
        # ...
        widget.Systray(
          background=colors[0],
          padding = 5
        ),
      ]
    
      return widgets_list