From b85616414afd14ce9f62c952a2be7fa82b3549a0 Mon Sep 17 00:00:00 2001 From: Sho Date: Sun, 2 Aug 2026 00:05:00 +0900 Subject: [PATCH] fix: update sync_discord to auto-enable quickshell-theme.css in settings.json and sync QuickCSS across native & Flatpak clients --- quickshell/services/python/theme_sync.py | 75 ++++++++++++++++++------ 1 file changed, 57 insertions(+), 18 deletions(-) diff --git a/quickshell/services/python/theme_sync.py b/quickshell/services/python/theme_sync.py index 91f07d9..7ab5e06 100644 --- a/quickshell/services/python/theme_sync.py +++ b/quickshell/services/python/theme_sync.py @@ -246,6 +246,7 @@ white = "{fg}" pass def sync_discord(bg, surface, current_line, fg, accent, sub_accent, is_dark): + import json css_content = f"""/* Auto-generated by Quickshell Theme Engine (Catppuccin Discord Architecture) */ .visual-refresh.theme-dark, .visual-refresh .theme-dark, .theme-dark, .theme-light, :root, html, body {{ --brand-500: {accent} !important; @@ -327,27 +328,65 @@ def sync_discord(bg, surface, current_line, fg, accent, sub_accent, is_dark): --user-profile-overlay-background: {surface} !important; }} """ - quick_css = os.path.expanduser('~/.config/equibop/settings/quickCss.css') - if os.path.exists(os.path.dirname(quick_css)): - with open(quick_css, 'w') as f: - f.write(css_content) - for client_dir in [ - os.path.expanduser('~/.config/vesktop/themes'), - os.path.expanduser('~/.config/Vencord/themes'), - os.path.expanduser('~/.config/equibop/themes'), - os.path.expanduser('~/.config/equicord/themes'), - os.path.expanduser('~/.config/discord/themes'), - os.path.expanduser('~/.var/app/dev.vencord.Vesktop/config/vesktop/themes'), - os.path.expanduser('~/.var/app/dev.vencord.Vesktop/config/Vencord/themes'), - os.path.expanduser('~/.var/app/com.discordapp.Discord/config/discord/themes'), - os.path.expanduser('~/.var/app/com.discordapp.Discord/config/Vencord/themes') + discord_dirs = get_app_config_dirs(['vesktop', 'Vencord', 'equibop', 'equicord', 'discord', 'Discord']) + for fb in [ + os.path.expanduser('~/.config/vesktop'), + os.path.expanduser('~/.config/Vencord'), + os.path.expanduser('~/.config/equibop'), + os.path.expanduser('~/.config/equicord'), + os.path.expanduser('~/.config/discord'), + os.path.expanduser('~/.var/app/dev.vencord.Vesktop/config/vesktop'), + os.path.expanduser('~/.var/app/dev.vencord.Vesktop/config/Vencord'), + os.path.expanduser('~/.var/app/com.discordapp.Discord/config/discord'), + os.path.expanduser('~/.var/app/com.discordapp.Discord/config/Vencord') ]: + if fb not in discord_dirs: + discord_dirs.append(fb) + + for base_dir in discord_dirs: try: - os.makedirs(client_dir, exist_ok=True) - css_file = os.path.join(client_dir, 'quickshell-theme.css') - with open(css_file, 'w', encoding='utf-8') as f: - f.write(css_content) + # 1. Write quickshell-theme.css to themes/ directory + themes_dir = os.path.join(base_dir, 'themes') + os.makedirs(themes_dir, exist_ok=True) + for theme_filename in ['quickshell-theme.css', 'quickshell.theme.css', 'quickshell.css']: + with open(os.path.join(themes_dir, theme_filename), 'w', encoding='utf-8') as f: + f.write(css_content) + + # 2. Write QuickCSS file + for qc_path in [ + os.path.join(base_dir, 'settings', 'quickCss.css'), + os.path.join(base_dir, 'quickCss.css') + ]: + os.makedirs(os.path.dirname(qc_path), exist_ok=True) + with open(qc_path, 'w', encoding='utf-8') as f: + f.write(css_content) + + # 3. Enable quickshell-theme.css and QuickCSS in settings.json + for s_path in [ + os.path.join(base_dir, 'settings', 'settings.json'), + os.path.join(base_dir, 'settings.json') + ]: + try: + os.makedirs(os.path.dirname(s_path), exist_ok=True) + s_data = {} + if os.path.exists(s_path): + with open(s_path, 'r', encoding='utf-8') as f: + s_data = json.load(f) + + enabled_themes = s_data.get('enabledThemes', []) + if not isinstance(enabled_themes, list): + enabled_themes = [] + if 'quickshell-theme.css' not in enabled_themes: + enabled_themes.append('quickshell-theme.css') + + s_data['enabledThemes'] = enabled_themes + s_data['useQuickCss'] = True + + with open(s_path, 'w', encoding='utf-8') as f: + json.dump(s_data, f, indent=2) + except Exception: + pass except Exception: pass