How to make it so that when i log into my pc (qtile), then qbittorrent automatically moves to workspace 8 on startup?

I’m a meganoob so to speak, so the best I’ve managed is that qtilestarts and qbittorrent runs on startup but its on the first workspace (not 8).

When you create the groups/workspaces you can add matches=[Match(wm_class=[<WM_CLASS of program>]) to the parameters when creating the Group object. It is described in the docs. For example Group('8', matches=[Match(wm_class=[<WM_CLASS of program>])).
To get the WM_CLASS you can run xprop WM_CLASS and click on the window.

Hey. Thank you for the reply. (y)

Via xprop I found out that the WM_CLASS of the app is qbittorrent. However I’m not quite sure where to put the

" Group(‘8’, matches=[Match(wm_class=[]))"

I’m slightly scared that if I put it in groups.py (mine looks like this), it will break my qtile :smiley:

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

groups = [Group(i) for i in "12345"]

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)),
    ])

The groups config variable is a list with all workspaces, so it is where you want to put it. You could do something like this:

groups = [Group(i) for i in '1234567']
groups.append(Group('8', matches=[Match(wm_class=['qbittorrent'])])
1 Like

hey. thank you for the reply :slight_smile: really appreciate it. I tried the line of code you suggested and I think I must have somehow used it wrong. tried two variations that made sense to me and both of them crashed my qtile setup.

Any thoughts what I’m missing here?

Version one was like this (neither of them worked):

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

groups = [Group(i) for i in "1234567"] groups.append(Group('6', matches=[Match(wm_class=['qbittorrent'])]) # startup qtile endeavour foorumist

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)),
    ])

Ver 2 (didnt work either)


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

groups = [Group(i) for i in "1234567"] 
groups.append(Group('6', matches=[Match(wm_class=['qbittorrent'])]) # startup qtile endeavour foorumist

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)),
    ])

The reason the first failed is because it is invalid python code. The groups.append(...) must be on a new line.
The reason for the second one failing would likely be that you append Group('6', ...) to groups when there already is a group with the same name and I suspect Qtile does not like there being two Group objects with the same name.

Thanks mate. Sadly it didn’t work. I tried the following solution (based on your suggestion) and same thing. No dice.

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

groups = [Group(i) for i in "1234567"] 
groups.append(Group('8', matches=[Match(wm_class=['qbittorrent'])]) #startup qtile endeavour foorumist

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)),
    ])