Created
April 7, 2020 13:42
-
-
Save m-col/627579cecc769776ec4b904b408dde87 to your computer and use it in GitHub Desktop.
Lock Qtile groups to screens
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
groups = [ | |
Group('1'), | |
Group('2'), | |
Group('3'), | |
Group('4'), | |
Group('5'), | |
] | |
def _go_to_group(group): | |
if num_monitors > 1: | |
if group in '123': | |
def _inner(qtile): | |
old = qtile.current_screen.group.name | |
qtile.cmd_to_screen(0) | |
if old in '123' or qtile.current_screen.group.name != group: | |
qtile.groups_map[group].cmd_toscreen() | |
else: | |
def _inner(qtile): | |
old = qtile.current_screen.group.name | |
qtile.cmd_to_screen(1) | |
if old in '45' or qtile.current_screen.group.name != group: | |
qtile.groups_map[group].cmd_toscreen() | |
else: | |
def _inner(qtile): | |
qtile.groups_map[group].cmd_toscreen() | |
return _inner | |
for i in groups: | |
keys.extend([ | |
Key([mod], i.name, lazy.function(_go_to_group(i.name))), | |
Key([mod, 'shift'], i.name, lazy.window.togroup(i.name)), | |
]) | |
def _scroll_screen(direction): | |
""" Scroll to next/prev group of subset allocated to specific screen """ | |
if num_monitors > 1: | |
def _inner(qtile): | |
current = qtile.groups.index(qtile.current_group) | |
if current < 3: | |
destination = (current + direction) % 3 | |
else: | |
destination = 3 if current == 4 else 4 | |
qtile.groups[destination].cmd_toscreen() | |
else: | |
def _inner(qtile): | |
current = qtile.groups.index(qtile.current_group) | |
destination = (current + direction) % 5 | |
qtile.groups[destination].cmd_toscreen() | |
return _inner | |
keys.extend([ | |
Key([mod], 'm', lazy.function(_scroll_screen(1))), | |
Key([mod], 'n', lazy.function(_scroll_screen(-1))), | |
EzKey('M-<Tab>', lazy.screen.toggle_group()), | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment