How to make "switch to group" and "move to group" keys work?

Hi every one,

When I do mod + digit (e.g. super+4) nothing happens, when I expect Qtile to switch to the 4th group.

Idem when I do Shift + mod + digit on an application, it is not sent to the expected group.

Here is my group.py:

# Imports

from libqtile.config import Key, Group, Match
from libqtile.command import lazy
from .keys import keys, mod

# Variables

groups = [
    Group("1"),
    Group("2", matches=[Match(wm_class=["chromium"])]),
    Group("3", matches=[Match(wm_class=["emacs"])]),
    Group("4", matches=[Match(wm_class=["keepassxc"])]),
    Group("5"),
    Group("6"),
    Group("7"),
    Group("8"),
    Group("9"),
]
mod = "mod4"

# Group config

for i in groups:
    keys.extend([
        # mod1 + letter of group = switch to group
        Key([mod],
            i.name,
            lazy.group[i.name].toscreen(),
            desc="Switch to group {}".format(i.name)),

        Key([mod], "Right", lazy.screen.next_group(),
            desc="Switch to next group"),

        Key([mod], "Left", lazy.screen.prev_group(),
            desc="Switch to previous group"),

        # mod1 + shift + letter of group = switch to & move focused window to group
        Key([mod, "shift"],
            i.name,
            lazy.window.togroup(i.name, switch_group=True),
            desc="Switch to & move focused window to group {}".format(i.name)),
        # Or, use below if you prefer not to switch to that group.
        # # mod1 + shift + letter of group = move focused window to group
        # Key([mod, "shift"], i.name, lazy.window.togroup(i.name),
        #     desc="move focused window to group {}".format(i.name)),
    ])

Try using this instead for your bindings on this:

# Allow MODKEY+[0 through 9] to bind to groups, see https://docs.qtile.org/en/stable/manual/config/groups.html
# MOD4 + index Number : Switch to Group[index]
# MOD4 + shift + index Number : Send active window to another Group

from libqtile.dgroups import simple_key_binder
dgroups_key_binder = simple_key_binder("mod4")

This is what I have in my config.

I did that already, following this doc, but it didn’t work…

There is something else in your config.py that is overriding it, that’s exactly the problem I had by default. I just can’t remember the exact name. Can you share your config.py?

I found it. The following is in the default config.py so it may there. If it is, just remove it:


dgroups_key_binder = None

It’s overriding the other settings we talked about here. At least, like I said, that’s what I ran into.

I removed it already as indicated in the documentation I mentioned, but it didn’t solve the issue.

When testing dgroups_key_binder,

config.py :

  from modules.keys import keys, mod
  from modules.groups import groups
  from modules.layouts import layouts, floating_layout
  from modules.mouse import mouse
  from modules.hooks import *
  import os
  from modules.screens import screens
  #dgroups_key_binder = None
  #dgroups_key_binder = simple_key_binder("mod4")
  #dgroups_app_rules = ["1","2","3","4","5","6","7","8","9"]  # type: List
  main = None  # WARNING: this is deprecated and will be removed soon
  follow_mouse_focus = True
  bring_front_click = False
  cursor_warp = False
  auto_fullscreen = True
  focus_on_window_activation = "smart"
  wmname = "Qtile"
  widget_defaults = dict(
	  font='Cascadia Code',
	  fontsize=18,
	  padding=3
  )

group.py:

  from libqtile.config import Key, Group, Match
  from libqtile.command import lazy
  from .keys import keys, mod
  groups = [
      Group("1"),
      Group("2", matches=[Match(wm_class=["chromium"])]),
      Group("3", matches=[Match(wm_class=["emacs"])]),
      Group("4", matches=[Match(wm_class=["keepassxc"])]),
      Group("5"),
      Group("6"),
      Group("7"),
      Group("8"),
      Group("9"),
  ]
  from libqtile.dgroups import simple_key_binder
  dgroups_key_binder = simple_key_binder("mod4")

instead of having matches from 2 through 4, make it begin from Group 1 through 3. Change another key binding and try pressing hotkey + 0 and hotkey + 1

sorry i have limited resource now and hence could not test your config. Just shooting in the sky for now.

When I do remove matches, the result is the same.