Unify configs so we can get rid of all those branches per machine. Also Wayland changes for Violet

This commit is contained in:
Kevin Alberts 2025-07-25 17:39:36 +02:00
parent 5a0041e7d5
commit 6dd362247e
10 changed files with 274 additions and 105 deletions

View file

@ -1,6 +1,7 @@
import json
import os
import random
import time
import datetime
import socket
import subprocess
@ -39,14 +40,11 @@ from kuro.utils import layouts as kuro_layouts
logger.warning("Importing configuration...")
try:
from kuro.config import Config
except ImportError:
try:
from kuro.baseconfig import BaseConfig as Config
except ImportError:
Config = None
raise ImportError("Could not load theme Config or BaseConfig!")
from kuro.utils import load_config_class
Config = load_config_class()
if Config is None:
raise ImportError("Could not load theme Config or BaseConfig! Error: {}".format(e))
Config.initialize(qtile)
logger.warning("Imports done")
@ -58,9 +56,6 @@ class Kuro(BaseTheme):
# Screen count
num_screens = 0
# Top bars
topbars = []
# Static windows
static_windows = []
@ -310,9 +305,6 @@ class Kuro(BaseTheme):
Config.bar_background = colors['color1']
def reinit_screens(self):
# Re-initalize bars
self.topbars.clear()
# TODO: Move backend check into utils method
if qtile.core.name == "x11":
self.num_screens = max(1, utils.get_screen_count())
@ -320,18 +312,19 @@ class Kuro(BaseTheme):
self.num_screens = max(1, len(qtile.core.get_screen_info()))
logger.warning(f"Detected {self.num_screens} screens.")
# TODO: If i get the double topbar issue, this might be the
# cause; creating new screens on reinit...
screens = []
for x in range(self.num_screens):
logger.warning("Initializing bars for screen {}".format(x))
topbar = self.build_bar_for_screen(x)
self.topbars.append(topbar)
screens.append(Screen(top=topbar))
logger.warning("Reconfiguring bars for screen {}".format(x))
self.screens.clear()
for s in screens:
self.screens.append(s)
try:
screen = self.screens[x]
except IndexError:
screen = Screen()
if screen.top is None:
screen.top = self.build_bar_for_screen(x)
topbar = screen.top
self.screens.append(Screen(top=topbar))
def update_keys(self):
logger.warning("Updating keys")
@ -606,7 +599,6 @@ class Kuro(BaseTheme):
# Update color scheme
self.update_colorscheme()
self.startup_completed = True
def callback_startup_complete(self, *args, **kwargs):
logger.warning("Callback Startup Complete")
@ -617,14 +609,20 @@ class Kuro(BaseTheme):
# Update color scheme
self.update_colorscheme()
# Setup XDG Desktop Portal
self.setup_xdg_desktop_portal()
# Setup XDG Desktop Portal on Wayland
if qtile.core.name == "wayland":
self.setup_xdg_desktop_portal()
# After first startup is complete, autostart configured apps
logger.warning("Autostarting apps...")
for app in Config.get("apps_autostart", []):
logger.warning(f"Starting '{app}'...")
utils.execute_once(app)
for category in Config.get("apps_autostart", {}).keys():
if qtile.core.name == category or category == "common":
logger.warning(f"Autostarting apps for {category}...")
for app in Config.get("apps_autostart", {}).get(category, []):
logger.warning(f"Starting '{app}'...")
utils.execute_once(app)
else:
logger.warning(f"Skipping autostart apps for {category}, because core is {qtile.core.name}...")
for app in Config.get("apps_autostart_group", []):
if all(x in app.keys() for x in ["group", "command"]):
@ -634,6 +632,9 @@ class Kuro(BaseTheme):
logger.warning(f"Invalid app in 'apps_autostart_group', "
f"must have 'group' and 'command' keys: {app}...")
logger.warning("Autostart complete")
cur_time = time.time()
logger.warning(f"QTile startup completed! Started up in {(cur_time - self.startup_time):.1f} seconds!")
self.startup_completed = True
def callback_client_managed(self, *args, **kwargs):
client: Optional[Window] = args[0] if len(args) > 0 else None
@ -667,9 +668,14 @@ class Kuro(BaseTheme):
del client.is_static_window
self.static_windows.remove(client)
def callback_screens_reconfigured(self, *args, **kwargs):
logger.warning(f"Re-configuring screens!")
def callback_screen_change(self, *args, **kwargs):
logger.warning(f"Screen configuration changed, reinitializing screens")
self.reinit_screens()
qtile.reconfigure_screens()
#qtile.reconfigure_screens() # Twice, see: https://github.com/qtile/qtile/issues/4673#issuecomment-2196459114
#def callback_screens_reconfigured(self, *args, **kwargs):
logger.warning(f"Screens were reconfgured, updating wallpapers and color scheme")
self.set_wallpaper(self.current_wallpaper)
self.update_colorscheme()