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:
parent
0b9b7a68eb
commit
b85616414a
@ -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)):
|
|
||||||
with open(quick_css, 'w') as f:
|
|
||||||
f.write(css_content)
|
|
||||||
|
|
||||||
for client_dir in [
|
discord_dirs = get_app_config_dirs(['vesktop', 'Vencord', 'equibop', 'equicord', 'discord', 'Discord'])
|
||||||
os.path.expanduser('~/.config/vesktop/themes'),
|
for fb in [
|
||||||
os.path.expanduser('~/.config/Vencord/themes'),
|
os.path.expanduser('~/.config/vesktop'),
|
||||||
os.path.expanduser('~/.config/equibop/themes'),
|
os.path.expanduser('~/.config/Vencord'),
|
||||||
os.path.expanduser('~/.config/equicord/themes'),
|
os.path.expanduser('~/.config/equibop'),
|
||||||
os.path.expanduser('~/.config/discord/themes'),
|
os.path.expanduser('~/.config/equicord'),
|
||||||
os.path.expanduser('~/.var/app/dev.vencord.Vesktop/config/vesktop/themes'),
|
os.path.expanduser('~/.config/discord'),
|
||||||
os.path.expanduser('~/.var/app/dev.vencord.Vesktop/config/Vencord/themes'),
|
os.path.expanduser('~/.var/app/dev.vencord.Vesktop/config/vesktop'),
|
||||||
os.path.expanduser('~/.var/app/com.discordapp.Discord/config/discord/themes'),
|
os.path.expanduser('~/.var/app/dev.vencord.Vesktop/config/Vencord'),
|
||||||
os.path.expanduser('~/.var/app/com.discordapp.Discord/config/Vencord/themes')
|
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:
|
try:
|
||||||
os.makedirs(client_dir, exist_ok=True)
|
# 1. Write quickshell-theme.css to themes/ directory
|
||||||
css_file = os.path.join(client_dir, 'quickshell-theme.css')
|
themes_dir = os.path.join(base_dir, 'themes')
|
||||||
with open(css_file, 'w', encoding='utf-8') as f:
|
os.makedirs(themes_dir, exist_ok=True)
|
||||||
f.write(css_content)
|
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:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user