fix: update sync_discord to auto-enable quickshell-theme.css in settings.json and sync QuickCSS across native & Flatpak clients

This commit is contained in:
Sho 2026-08-02 00:05:00 +09:00
parent 0b9b7a68eb
commit b85616414a

View File

@ -246,6 +246,7 @@ white = "{fg}"
pass pass
def sync_discord(bg, surface, current_line, fg, accent, sub_accent, is_dark): 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) */ 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 {{ .visual-refresh.theme-dark, .visual-refresh .theme-dark, .theme-dark, .theme-light, :root, html, body {{
--brand-500: {accent} !important; --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; --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)): discord_dirs = get_app_config_dirs(['vesktop', 'Vencord', 'equibop', 'equicord', 'discord', 'Discord'])
with open(quick_css, 'w') as f: 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:
# 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) f.write(css_content)
for client_dir in [ # 2. Write QuickCSS file
os.path.expanduser('~/.config/vesktop/themes'), for qc_path in [
os.path.expanduser('~/.config/Vencord/themes'), os.path.join(base_dir, 'settings', 'quickCss.css'),
os.path.expanduser('~/.config/equibop/themes'), os.path.join(base_dir, 'quickCss.css')
os.path.expanduser('~/.config/equicord/themes'), ]:
os.path.expanduser('~/.config/discord/themes'), os.makedirs(os.path.dirname(qc_path), exist_ok=True)
os.path.expanduser('~/.var/app/dev.vencord.Vesktop/config/vesktop/themes'), with open(qc_path, 'w', encoding='utf-8') as f:
os.path.expanduser('~/.var/app/dev.vencord.Vesktop/config/Vencord/themes'), f.write(css_content)
os.path.expanduser('~/.var/app/com.discordapp.Discord/config/discord/themes'),
os.path.expanduser('~/.var/app/com.discordapp.Discord/config/Vencord/themes') # 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: try:
os.makedirs(client_dir, exist_ok=True) os.makedirs(os.path.dirname(s_path), exist_ok=True)
css_file = os.path.join(client_dir, 'quickshell-theme.css') s_data = {}
with open(css_file, 'w', encoding='utf-8') as f: if os.path.exists(s_path):
f.write(css_content) 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: except Exception:
pass pass