Commit 8335202bd0462ba37354f81c8f0503b700bfb110 Parent: 54d7075e9d3eef589a6b711c989e7334ed857f4e Author: mcol <mcol@posteo.net> Date: 2021-06-16 00:07:35 +0100 Committer: mcol <mcol@posteo.net> Committed: 2021-06-16 00:11:37 +0100 Move initial groups hook into group.py
groups.py Modified
@@ -12,6 +12,7 @@ import os from typing import TYPE_CHECKING +from libqtile import hook, qtile from libqtile.config import Group, Match from libqtile.lazy import lazy @@ -94,3 +95,20 @@ ([mod], 'm', lazy.function(_scroll_screen(1)), "Screen groups forward"), ([mod], 'n', lazy.function(_scroll_screen(-1)), "Screen groups backward"), ]) + + +@hook.subscribe.startup +def _(): + # Set initial groups + if len(qtile.screens) > 1: + qtile.groups_map['1'].cmd_toscreen(0, toggle=False) + qtile.groups_map['q'].cmd_toscreen(1, toggle=False) + + +@hook.subscribe.screen_change +def _(): + # Set groups to screens + if len(qtile.screens) > 1: + if qtile.screens[0].group.name not in '123': + qtile.groups_map['1'].cmd_toscreen(0, toggle=False) + qtile.groups_map['q'].cmd_toscreen(1, toggle=False)
config.py Modified
@@ -402,6 +402,26 @@ widget.GroupBox(**groupbox_config, visible_groups=['q', 'w', 'e']), ] +@hook.subscribe.startup +def _(): + # Set up initial GroupBox visible groups + if len(qtile.screens) > 1: + groupboxes[0].visible_groups = ['1', '2', '3'] + else: + groupboxes[0].visible_groups = ['1', '2', '3', 'q', 'w', 'e'] + +@hook.subscribe.screen_change +async def _(_): + # Reconfigure GroupBox visible groups + await asyncio.sleep(1) # Am I gonna fix this? + if len(qtile.screens) > 1: + groupboxes[0].visible_groups = ['1', '2', '3'] + else: + groupboxes[0].visible_groups = ['1', '2', '3', 'q', 'w', 'e'] + if hasattr(groupboxes[0], 'bar'): + groupboxes[0].bar.draw() + + screens = [ Screen( bottom=bar.Bar( @@ -436,17 +456,6 @@ # Hooks -@hook.subscribe.startup -def _(): - # Set initial groups - if len(qtile.screens) > 1: - qtile.groups_map['1'].cmd_toscreen(0, toggle=False) - qtile.groups_map['q'].cmd_toscreen(1, toggle=False) - groupboxes[0].visible_groups = ['1', '2', '3'] - else: - groupboxes[0].visible_groups = ['1', '2', '3', 'q', 'w', 'e'] - - if IS_WAYLAND: from libqtile.backend.wayland.window import Window @hook.subscribe.client_new @@ -471,21 +480,6 @@ window.floating = True -@hook.subscribe.screen_change -async def _(_): - # Set up GroupBox visible groups - await asyncio.sleep(1) - if len(qtile.screens) > 1: - groupboxes[0].visible_groups = ['1', '2', '3'] - if qtile.screens[0].group.name not in "123": - qtile.groups_map['1'].cmd_toscreen(0, toggle=False) - qtile.groups_map['q'].cmd_toscreen(1, toggle=False) - else: - groupboxes[0].visible_groups = ['1', '2', '3', 'q', 'w', 'e'] - if hasattr(groupboxes[0], 'bar'): - groupboxes[0].bar.draw() - - ## Startup script for Wayland if IS_WAYLAND: @hook.subscribe.startup_once