internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: qtile/qtile

Issue:
qtile top breaks when the terminal is too small
I just launched `qtile top` several times but it only worked once, and broke on the next runs:

```
$ qtile top --force-start
$ qtile top
Traceback (most recent call last):
  File "libqtile/scripts/main.py", line 46, in main
    options.func(options)
  File "qtile/libqtile/scripts/top.py", line 158, in top
    force_start=force_start)
  File "/usr/lib/python3.7/curses/__init__.py", line 102, in wrapper
    return func(stdscr, *args, **kwds)
  File "libqtile/scripts/top.py", line 95, in get_stats
    scr.addstr(cnt + 1, 0, '{:<3} {:<40} {:<30}'.format(index, filename, mem))
_curses.error: addwstr() returned ERR
```

Also I'm not sure what's happening, but I can't replicate this in another X session, whether I use PYTHONTRACEMALLOC or --force-start.


Discussion:
Seems like maybe it depends on the size of your terminal:

https://stackoverflow.com/questions/54409924/curses-error-addwstr-returned-err-on-changing-nlines-to-1-on-newwin-method

maybe `curses.wrapper` doesn't restore everything entirely correctly?
Uh, yeah, I should have used Google. :)

It indeed breaks when the terminal is too small.

Resolving patch:
diff --git a/libqtile/scripts/top.py b/libqtile/scripts/top.py
--- a/libqtile/scripts/top.py
+++ b/libqtile/scripts/top.py
@@ -167,6 +167,9 @@ def top(opts):
         print("Can't start tracemalloc on qtile, check the logs")
     except KeyboardInterrupt:
         exit(-1)
+    except curses.error:
+        print("Terminal too small for curses interface.")
+        raw_stats(client, limit=lines, force_start=force_start)
 
 
 def add_subcommand(subparsers):


Test patch:
Repository: qtile/qtile

Issue:
Don't crash if there are less groups than screens
[insert traceback here]



Discussion:
I can confirm that Qtile is badly crashing if there are less groups than screens, without any log. We should fallback to the default config and print an error in the logs.

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -112,9 +112,7 @@ def load_config(self):
             warnings.warn("Defining a main function is deprecated, use libqtile.qtile", DeprecationWarning)
             self.config.main(self)
 
-        if self.config.groups:
-            self.dgroups = DGroups(self, self.config.groups,
-                                   self.config.dgroups_key_binder)
+        self.dgroups = DGroups(self, self.config.groups, self.config.dgroups_key_binder)
 
         if self.config.widget_defaults:
             _Widget.global_defaults = self.config.widget_defaults
@@ -288,9 +286,15 @@ def _process_screens(self) -> None:
             if not self.current_screen:
                 self.current_screen = scr
 
-            scr._configure(
-                self, i, x, y, w, h, self.groups[i],
-            )
+            if len(self.groups) < i + 1:
+                name = f"autogen_{i + 1}"
+                self.add_group(name)
+                grp = self.groups[i]
+                logger.warning(f"Too few groups in config. Added group: {name}")
+            else:
+                grp = self.groups[i]
+
+            scr._configure(self, i, x, y, w, h, grp)
             self.screens.append(scr)
 
     def paint_screen(self, screen, image_path, mode=None):


Test patch:
diff --git a/test/test_manager.py b/test/test_manager.py
--- a/test/test_manager.py
+++ b/test/test_manager.py
@@ -215,6 +215,17 @@ def test_keypress(manager):
     assert manager.c.groups()["a"]["focus"] == "one"
 
 
+class TooFewGroupsConfig(ManagerConfig):
+    groups = []
+
+
+@pytest.mark.parametrize("manager", [TooFewGroupsConfig], indirect=True)
+@pytest.mark.parametrize("xephyr", [{"xinerama": True}, {"xinerama": False}], indirect=True)
+def test_too_few_groups(manager):
+    assert manager.c.groups()
+    assert len(manager.c.groups()) == len(manager.c.screens())
+
+
 class _ChordsConfig(Config):
     groups = [
         libqtile.config.Group("a")
Repository: qtile/qtile

Issue:
Missing widget requirements in documentation
# Issue description
The CPU and CPUGraph widgets do not work without psutil, but this isn't mentioned in the documentation for Built-in Widgets.

[http://docs.qtile.org/en/latest/manual/ref/widgets.html#cpu](http://docs.qtile.org/en/latest/manual/ref/widgets.html#cpu)
[http://docs.qtile.org/en/latest/manual/ref/widgets.html#cpugraph](http://docs.qtile.org/en/latest/manual/ref/widgets.html#cpugraph)

# Qtile version
Release 0.16.1

# Stack traces
N/A

# Configuration
Irrelevant



Discussion:
Thanks for flagging. I'll submit a PR for this later.

Resolving patch:
diff --git a/libqtile/widget/cpu.py b/libqtile/widget/cpu.py
--- a/libqtile/widget/cpu.py
+++ b/libqtile/widget/cpu.py
@@ -24,6 +24,13 @@
 
 
 class CPU(base.ThreadPoolText):
+    """
+    A simple widget to display CPU load and frequency.
+
+    Widget requirements: psutil_.
+
+    .. _psutil: https://pypi.org/project/psutil/
+    """
     orientations = base.ORIENTATION_HORIZONTAL
 
     defaults = [
diff --git a/libqtile/widget/graph.py b/libqtile/widget/graph.py
--- a/libqtile/widget/graph.py
+++ b/libqtile/widget/graph.py
@@ -192,7 +192,12 @@ def fulfill(self, value):
 
 
 class CPUGraph(_Graph):
-    """Display CPU usage graph"""
+    """Display CPU usage graph.
+
+    Widget requirements: psutil_.
+
+    .. _psutil: https://pypi.org/project/psutil/
+    """
     orientations = base.ORIENTATION_HORIZONTAL
     defaults = [
         ("core", "all", "Which core to show (all/0/1/2/...)"),
@@ -240,7 +245,12 @@ def update_graph(self):
 
 
 class MemoryGraph(_Graph):
-    """Displays a memory usage graph"""
+    """Displays a memory usage graph.
+
+    Widget requirements: psutil_.
+
+    .. _psutil: https://pypi.org/project/psutil/
+    """
     orientations = base.ORIENTATION_HORIZONTAL
     fixed_upper_bound = True
 
@@ -269,7 +279,12 @@ def update_graph(self):
 
 
 class SwapGraph(_Graph):
-    """Display a swap info graph"""
+    """Display a swap info graph.
+
+    Widget requirements: psutil_.
+
+    .. _psutil: https://pypi.org/project/psutil/
+    """
     orientations = base.ORIENTATION_HORIZONTAL
     fixed_upper_bound = True
 
@@ -300,7 +315,11 @@ def update_graph(self):
 
 
 class NetGraph(_Graph):
-    """Display a network usage graph"""
+    """Display a network usage graph.
+
+    Widget requirements: psutil_.
+
+    .. _psutil: https://pypi.org/project/psutil/"""
     orientations = base.ORIENTATION_HORIZONTAL
     defaults = [
         (


Test patch:
Repository: qtile/qtile

Issue:
Missing requirement in documentation for Volume widget
# Issue description
The Volume widget by default needs access to amixer, which is part of the package alsa-utils, unless the `get_volume_command` is manually set to something else by the user.

This is not mentioned in the documentation [http://docs.qtile.org/en/latest/manual/ref/widgets.html#volume](http://docs.qtile.org/en/latest/manual/ref/widgets.html#volume)

# Qtile version
0.16.1

# Stack traces
N/A

# Configuration
Irrelevant



Discussion:

Resolving patch:
diff --git a/libqtile/widget/volume.py b/libqtile/widget/volume.py
--- a/libqtile/widget/volume.py
+++ b/libqtile/widget/volume.py
@@ -46,6 +46,10 @@
 class Volume(base._TextBox):
     """Widget that display and change volume
 
+    By default, this widget uses ``amixer`` to get and set the volume so users
+    will need to make sure this is installed. Alternatively, users may set the
+    relevant parameters for the widget to use a different application.
+
     If theme_path is set it draw widget as icons.
     """
     orientations = base.ORIENTATION_HORIZONTAL


Test patch:
Repository: qtile/qtile

Issue:
Feature: User keybinding for canceling the current chord mode
Hi, I use the qtile's KeyChord's rather extensively and have several modes set up with them. However I recently tried to figure out if there is a way to get out of the current mode by any means other than pressing Escape. I'm not too familiar with qtile's internals, but I've found this: https://github.com/qtile/qtile/blob/b00e417a20b461d46ad48e11539948a1fc10eeb7/libqtile/core/manager.py#L372 which suggests the answer is "no", it appears Escape is hard coded as the only way to cancel the chord and mode.

I would prefer if I could set some custom key binding to do so (preferably per mode) so I can set something closer to the home row for this instead of reaching for the Escape key. In Vim, for example, you can also get out of Insert Mode by pressing Ctrl+c. So, I would really love it if I could do something like this:

```
KeyChord([mod], "a", [
    ...subcommands...
    Key(["control"], "c", lazy.cancel_chord()),
], "mymode")
```

Like I said above, I'm not too familiar with qtile's internals and I'm not sure how difficult this would be. I haven't done Python programming in a decade, but with a shove in the right direction I might be able to put together a PR.


Discussion:
Sounds reasonable to me, @Miziak thoughts?
@rbobrowicz I suppose a start would be to possibly change `if self.current_chord is True or (self.current_chord and key.key == "Escape"):` to `if self.current_chord is True or (self.current_chord and key.key in ["Escape"] + keyChordEscapes):`?
```py
Key(['control'], 'g', lazy.function(lambda qtile: qtile.ungrab_chord())),
```
seems to work, see https://github.com/qtile/qtile/blob/7ec0bdd002ea44417bb2c439aca466f382ce80a5/libqtile/core/manager.py#L348-L350

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -346,7 +346,7 @@ def process_key_event(self, keysym: int, mask: int) -> None:
                         logger.error("KB command error %s: %s" % (cmd.name, val))
             else:
                 if self.current_chord is True or (self.current_chord and key.key == "Escape"):
-                    self.ungrab_chord()
+                    self.cmd_ungrab_chord()
                 return
 
     def grab_keys(self) -> None:
@@ -382,7 +382,7 @@ def grab_chord(self, chord) -> None:
         for key in chord.submapings:
             self.grab_key(key)
 
-    def ungrab_chord(self) -> None:
+    def cmd_ungrab_chord(self) -> None:
         self.current_chord = False
         hook.fire("leave_chord")
 


Test patch:
Repository: qtile/qtile

Issue:
qtile shell : error generated by 'cd' command.
# Issue description
My qtile shell ended with an error after I type a "cd" command without a path.
I was expected to go back to the root or to get a "no such path" message.

# Qtile version
git show-ref v0.17.0
fcde02230915b603c36f391deb78db2c0ca35a08 refs/tags/v0.17.0

# Stack traces
```
[bernard@vmArchqTile ~]$ qtile shell
 > ls
bar/     group/   layout/  screen/  widget/  window/
 > cd bar
bar
bar > ls
top/
bar > cd top/
bar[top]
bar[top] > help
help command   -- Help for a specific command.

Builtins
========
cd    exit  help  ls    pwd   q     quit

Commands for this object
========================
commands           doc                eval               fake_button_press
function           info               items            
bar[top] > cd titi
No such path.
bar[top] > cd
Traceback (most recent call last):
  File "/usr/bin/qtile", line 33, in <module>
    sys.exit(load_entry_point('qtile==0.17.0', 'console_scripts', 'qtile')())
  File "/usr/lib/python3.9/site-packages/libqtile/scripts/main.py", line 59, in main
    options.func(options)
  File "/usr/lib/python3.9/site-packages/libqtile/scripts/shell.py", line 35, in qshell
    qsh.loop()
  File "/usr/lib/python3.9/site-packages/libqtile/sh.py", line 348, in loop
    val = self.process_line(line)
  File "/usr/lib/python3.9/site-packages/libqtile/sh.py", line 308, in process_line
    val = builtin(args)
  File "/usr/lib/python3.9/site-packages/libqtile/sh.py", line 209, in do_cd
    next_node = self._find_path(arg)
  File "/usr/lib/python3.9/site-packages/libqtile/sh.py", line 152, in _find_path
    root = graph.CommandGraphRoot() if path.startswith("/") else self._current_node
AttributeError: 'NoneType' object has no attribute 'startswith'
[bernard@vmArchqTile ~]$
```

# Configuration
Not relevant I think.



Discussion:

Resolving patch:
diff --git a/libqtile/sh.py b/libqtile/sh.py
--- a/libqtile/sh.py
+++ b/libqtile/sh.py
@@ -201,6 +201,9 @@ def do_cd(self, arg) -> str:
 
             cd ../layout
         """
+        if arg is None:
+            self._current_node = graph.CommandGraphRoot()
+            return '/'
         next_node = self._find_path(arg)
         if next_node is not None:
             self._current_node = next_node


Test patch:
diff --git a/test/test_sh.py b/test/test_sh.py
--- a/test/test_sh.py
+++ b/test/test_sh.py
@@ -86,6 +86,7 @@ def test_do_cd(manager):
     assert sh.do_cd("..") == '/'
     assert sh.do_cd("layout") == 'layout'
     assert sh.do_cd("0/wibble") == 'No such path.'
+    assert sh.do_cd(None) == '/'
 
 
 @sh_config
Repository: qtile/qtile

Issue:
widget.LaunchBar padding background color
# Issue description

When the widget.LaunchBar is used with a padding greater than 0 (zero), the rightmost padding does not respect the bar background color. 

# Qtile version

0.17.0

# Configuration

```
screens = [
    Screen(
        top=bar.Bar(
            [
                widget.CurrentLayoutIcon(),
                widget.GroupBox(),
                widget.Prompt(),
		        widget.LaunchBar(
		            [      
		                ("google-chrome", "google-chrome-stable", "Launch Google Chrome"),
                        ("firefox", "firefox", "Launch Google Firefox"),
		            ],
                    padding=15
                ),
		        widget.Spacer(),
                widget.Clock(format='%a %d %b %Y %I:%M %p'),
		        widget.Spacer(),
                widget.Systray(),
                widget.QuickExit(),
            ],
	        29, background="#008880", opacity=.5
        ),
    ),
]
```
![2021-03-16-190402_436x32_scrot](https://user-images.githubusercontent.com/50297059/111395278-76b34100-868a-11eb-9b26-447083e6ab4d.png)



Discussion:
Looking at the source code, it does appear that, while the background colour is set, the widget never actually draws to that final bit of padding.

Can you do a pull request for this or do you need someone else to?

Resolving patch:
diff --git a/libqtile/widget/launchbar.py b/libqtile/widget/launchbar.py
--- a/libqtile/widget/launchbar.py
+++ b/libqtile/widget/launchbar.py
@@ -217,6 +217,8 @@ def draw(self):
             self.drawer.draw(offsetx=self.offset + xoffset,
                              width=icon_width + self.padding)
             xoffset += icon_width + self.padding
+        if self.padding:
+            self.drawer.draw(offsetx=self.offset + xoffset, width=self.padding)
 
     def calculate_length(self):
         """ Compute the width of the widget according to each icon width. """


Test patch:
Repository: qtile/qtile

Issue:
Formatting issue in docs
# Issue description

As reported in qtile-dev group, there's a formatting bug in the docs where the parameter name and type are joined into a single word.

See example here: https://docs.qtile.org/en/latest/manual/config/groups.html#group

I'm not familiar with sphinx so I'm not immediately sure how to fix this.

# Qtile version

Latest

EDIT:
On the docs site, in v0.16.1 there was a colon between the parameter and its type. However, testing locally I have that colon showing even with the latest version.




Discussion:

Resolving patch:
diff --git a/libqtile/config.py b/libqtile/config.py
--- a/libqtile/config.py
+++ b/libqtile/config.py
@@ -481,37 +481,38 @@ class Group:
 
     Parameters
     ==========
-    name : string
+    name: string
         the name of this group
-    matches : default ``None``
+    matches: default ``None``
         list of ``Match`` objects whose  windows will be assigned to this group
-    exclusive : boolean
+    exclusive: boolean
         when other apps are started in this group, should we allow them here or not?
-    spawn : string or list of strings
+    spawn: string or list of strings
         this will be ``exec()`` d when the group is created, you can pass
         either a program name or a list of programs to ``exec()``
-    layout : string
+    layout: string
         the name of default layout for this group (e.g. 'max' or 'stack').
         This is the name specified for a particular layout in config.py
         or if not defined it defaults in general the class name in all lower case.
-    layouts : list
+    layouts: list
         the group layouts list overriding global layouts.
         Use this to define a separate list of layouts for this particular group.
-    persist : boolean
+    persist: boolean
         should this group stay alive with no member windows?
-    init : boolean
+    init: boolean
         is this group alive when qtile starts?
-    position : int
+    position  int
         group position
-    label : string
+    label: string
         the display name of the group.
         Use this to define a display name other than name of the group.
         If set to None, the display name is set to the name.
     """
-    def __init__(self, name, matches=None, exclusive=False,
-                 spawn=None, layout=None, layouts=None, persist=True, init=True,
+    def __init__(self, name: str, matches: List[Match] = None, exclusive=False,
+                 spawn: Union[str, List[str]] = None, layout: str = None,
+                 layouts: List = None, persist=True, init=True,
                  layout_opts=None, screen_affinity=None, position=sys.maxsize,
-                 label=None):
+                 label: Optional[str] = None):
         self.name = name
         self.label = label
         self.exclusive = exclusive


Test patch:
Repository: qtile/qtile

Issue:
Bad icon scaling in Systray widget
# Issue description
1. I added the system tray widget to my qtile bar with an icon size of 20.
2. I currently use the icon set Papirus Dark.
3. I launched the `nm-applet` through the autostart script and I obtained a really small icon for the `nm-applet` as you can see in the following image: 

![image](https://user-images.githubusercontent.com/31258166/116829694-d0a09500-ab6a-11eb-805e-8f0e6a8cb91c.png)

The previous small icon also happened if I launched `nm-applet` through the terminal. 

One way I found to correct it was to setting the **icon size for the system tray to 16**. With this icon size, I obtained the following good results:

![image](https://user-images.githubusercontent.com/31258166/116829734-2412e300-ab6b-11eb-9687-e7121be99d21.png)

# Qtile version
`qtile 0.17.0`

# Configuration

My configuration can be found in the following [dotfiles](https://github.com/juanscr/dotfiles/tree/master/.config/qtile)



Discussion:
I'm pretty sure this happens if the icon defines a `min_width` and `min_height` hint and these are smaller than your set `icon_size`. Looking at the code, there's nothing to increase the `icon_size` in that scenario.

I'll submit a PR with a potential fix. Would be good if you could test.

Resolving patch:
diff --git a/libqtile/widget/systray.py b/libqtile/widget/systray.py
--- a/libqtile/widget/systray.py
+++ b/libqtile/widget/systray.py
@@ -55,19 +55,15 @@ def update_size(self):
         icon_size = self.systray.icon_size
         self.update_hints()
 
-        try:
-            width = self.hints["min_width"]
-            height = self.hints["min_height"]
-        except KeyError:
-            width = icon_size
-            height = icon_size
+        width = self.hints.get("min_width", icon_size)
+        height = self.hints.get("min_height", icon_size)
+
+        width = max(width, icon_size)
+        height = max(height, icon_size)
 
         if height > icon_size:
             width = width * icon_size // height
             height = icon_size
-        if height <= 0:
-            width = icon_size
-            height = icon_size
 
         self.width = width
         self.height = height


Test patch:
Repository: qtile/qtile

Issue:
Widgets missing from docs
Some widgets seem to have disappeared from the [official docs](http://docs.qtile.org/en/latest/manual/ref/widgets.html) (specifically `Mpris2` and `KeyboardKbdd`).

Given that these are two widgets that I've done some work on, it may be linked to that (but not immediately sure how).

I can do some bisecting and report back.

# Qtile version

Latest (3fb1e46 at time of posting)


EDIT: I can't replicate this on my system. However, given the identity of the two widgets, my guess is that this is related to `dbus-next` and that the modules need to be included in the `docs\conf.py` file here:
https://github.com/qtile/qtile/blob/3fb1e4645910c67bf6d302d59302dfb88f10c4ad/docs/conf.py#L27-L48

I'll submit a PR on that basis.




Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -33,6 +33,10 @@ def __dir__(self):
     'cffi',
     'dateutil',
     'dateutil.parser',
+    'dbus_next',
+    'dbus_next.aio',
+    'dbus_next.service',
+    'dbus_next.constants',
     'iwlib',
     'keyring',
     'mpd',


Test patch:
Repository: qtile/qtile

Issue:
Wayland: incorrect mouse pointer
I've noticed that, when using the Wayland backend, I get the incorrect mouse pointer. It shows the "select text" pointer even when mousing over the bar.

Flagging this now but I'll see if I can I identify some steps to recreate this reliably.

# Qtile version

Seen on 50a4adf but was present before too.



Discussion:
Nice catch. From a quick test I noticed if I'm in `Max` and move the pointer from Firefox to my Bar it stays as an ugly icon set by Firefox. In my `Columns` there is a gap between Firefox and the Bar and the pointer is changed back to my nice pointer when it goes over the desktop. So it looks like the pointer is being restored to normal when it is not over a window, but it should do this either when it is not over a window _or_ it moves over a Bar. Is that consistent with what you're seeing?
Ah, interesting.

Yes. If I'm in `Max` and open, say, an Alacritty terminal, I get the select text pointer. Moving to the bar doesn't change that pointer. However, if I do switch to another layout e.g. `MonadTall` then the pointer changes when it leaves the window.

Resolving patch:
diff --git a/libqtile/backend/wayland/core.py b/libqtile/backend/wayland/core.py
--- a/libqtile/backend/wayland/core.py
+++ b/libqtile/backend/wayland/core.py
@@ -386,6 +386,12 @@ def _process_cursor_motion(self, time):
                         self.cursor.y - self._hovered_internal.y
                     )
                 else:
+                    if self._hovered_internal:
+                        self._hovered_internal.process_pointer_leave(
+                            self.cursor.x - self._hovered_internal.x,
+                            self.cursor.y - self._hovered_internal.y
+                        )
+                    self.cursor_manager.set_cursor_image("left_ptr", self.cursor)
                     self.seat.pointer_clear_focus()
                     win.process_pointer_enter(self.cursor.x, self.cursor.y)
                     self._hovered_internal = win
@@ -422,7 +428,10 @@ def _process_cursor_motion(self, time):
             self.cursor_manager.set_cursor_image("left_ptr", self.cursor)
             self.seat.pointer_clear_focus()
             if self._hovered_internal:
-                self._hovered_internal.process_pointer_leave(self.cursor.x, self.cursor.y)
+                self._hovered_internal.process_pointer_leave(
+                    self.cursor.x - self._hovered_internal.x,
+                    self.cursor.y - self._hovered_internal.y
+                )
                 self._hovered_internal = None
 
     def _process_cursor_button(self, button: int, pressed: bool):


Test patch: