linking groups - thinking

  1. have different groups on different screens
  2. assign i to screen 1 and i+10 to screen 2
  • use mod + , to toggle between screens, when one screen disconnects
  1. will have to check if screen 2 exists or not

code

 
@lazy.function
def move_window_to_alternate_group(qtile):
 
    group = int(qtile.current_group.name) 
    if group < 10:
        qtile.current_window.togroup(str(group + 10))
    else:
        qtile.current_window.togroup(str(group - 10))
 
keys.extend([Key([mod], "comma", focus_group, desc="Next monitor"),])
 
 
@lazy.function
def focus_group(qtile):
    group = int(qtile.current_group.name) 
 
    if len(qtile.screens) > 1:
        qtile.next_screen()
    else:
        group = int(qtile.current_group.name) 
        if group < 10:
            qtile.current_screen.toggle_group(str(group + 10))
        else:
            qtile.current_screen.toggle_group(str(group - 10))
 
 
    # maybe works api
    # qtile.current_group.switch_groups('9')
    # ^ works but group object needs to be passed
    # qtile.groups_map['1'].to_screen()
    # qtile.current_screen.set_group('11')
 
 
keys.extend([Key([mod , "shift"], "comma", move_window_to_alternate_group, desc="Next monitor"),])
 
 
 
groups = []
for i in range(0,20):
    groups.append(Group(str(i)))
 
 
for i in range(0,10):
    keys.extend(
        [
            # navigation 
            # lazy.group[group.name].toscreen(toggle=True),
            Key([mod], str(i), lazy.group[str(i)].toscreen(0), lazy.group['1' + str(i)].toscreen(1)),
            # move window to group
            # Key([mod, "shift"], group.name, lazy.window.togroup(group.name),
            Key([mod, "shift"], str(i), lazy.window.togroup( '1' + str(i))),
        ]
    )
 

references

Feature request: allow windows from the same group to be present on multiple screens (i.e.allow groups to span screens) · qtile/qtile · Discussion #3035 · GitHub

I don’t imagine we will implement this internally as we prefer to keep things flexible and configurable enough for users to define their own specific behaviour. This use case is a good example of this as it’s already possible (with a bit of work!).

My first thought of how to implement it was slightly different than using the hooks - instead you could define your keybindings to directly modify pairs of groups so that they always are kept together. E.g. mod+1 could move group A and B to the screens, mod+2 would move groups C and D to the screens. Similarly mod+shift+1 could move the current window to group A or B depending on whether it was on an odd numbered group (i.e. C, E) or even (i.e. D, F). From the keybindings point of view you are considering pairs of groups as a single workspace. If you use GroupBox you could make it only display groups A, C, E etc so that it gives you a consistent experience.