Move multiple groups at once

Hi All,

I’ve exhausted the help I can get from chatGPT and I while I am also trying hard, I am far from a developer so I was wondering if anyone can help. I’m trying to write a function that will, when bound to a hotkey, simultaneously move groups 4, 5, and 6 to screens 1, 2, and 3. And also the same thing to move groups 1, 2, and 3 in the same fashion.

The use case is: I keep personal apps on 1, 2, and 3, and my work apps on 4, 5, and 6. It would be super helpful to have a fast way to just get one set of groups on all three screens then switch to the other set. Any help or even pointers in the right direction would be highly appreciated. I’ve been playing with groups and toscreen, to_screen, etc. but just can’t seem to bring it all together.

1 Like

I got some help from the cross post on Reddit. If anyone has interest in doing similar, here is the code for to make this work:

is_toggled = True
def move_to_screen(qtile):
    global is_toggled
    if is_toggled:
        is_toggled = False
        is_toggled = True

Then here is the key binding:

Key([mod], "w", lazy.function(move_to_screen), desc="test function"),

1 Like

just adding a few cents.

dont know if it is relevant here. Though i am using Qtile, at this point cant remember what is a group.

generally to speed up things if you could decide on the default state. Lets say is_toggled == True

then you will only need to do one check if is_toggled == False. This is not specific to Qtile but a general idea for python.

A group is just the term Qtile uses for a “workspace”. So the above is moving workspaces to the monitors collectively.

Again, as a non-developer here, the function’s if statement as written starts by evaluating if is_toggled is true, thus why it’s set ahead of time. As usual in programming there are probably 12 ways to do it. I’m just happy having one that works :slight_smile:

1 Like

yeap no harm. you did great for a non-developer.

I got to something that kind of, sort of, looked like that, if you glanced at it sideways through a fogged up mirror. I had help :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.