fix: remove fastfetch overwriting from theme_sync.py and use ~/.config/fastfetch as reference

This commit is contained in:
Sho 2026-08-01 23:51:21 +09:00
parent 90634d2977
commit b01a8cc752
3 changed files with 90 additions and 147 deletions

View File

@ -1,80 +1,89 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"source": "~/.config/fastfetch/hamster_cookie.txt",
"type": "file",
"padding": {
"top": 0,
"left": 1,
"right": 3
}
},
"display": {
"separator": " ➜ ",
"color": {
"keys": "#a7c080",
"title": "#7fbbb3"
}
},
"modules": [
"title",
"separator",
{
"type": "os",
"key": "OS",
"keyColor": "cyan"
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"source": "~/.config/fastfetch/hamster_cookie.txt",
"color": {
"1": "magenta",
"2": "yellow"
},
"padding": {
"top": 1,
"left": 2,
"right": 2
}
},
{
"type": "host",
"key": "Host",
"keyColor": "green"
"display": {
"separator": " ",
"color": {
"keys": "#a7c080",
"title": "#7fbbb3"
}
},
{
"type": "kernel",
"key": "Kernel",
"keyColor": "yellow"
},
{
"type": "uptime",
"key": "Uptime",
"keyColor": "blue"
},
{
"type": "packages",
"key": "Packages",
"keyColor": "magenta"
},
{
"type": "shell",
"key": "Shell",
"keyColor": "cyan"
},
{
"type": "terminal",
"key": "Terminal",
"keyColor": "green"
},
{
"type": "wm",
"key": "WM",
"keyColor": "yellow"
},
{
"type": "cpu",
"key": "CPU",
"keyColor": "blue"
},
{
"type": "gpu",
"key": "GPU",
"keyColor": "magenta"
},
{
"type": "memory",
"key": "Memory",
"keyColor": "red"
},
"break",
"colors"
]
"modules": [
{
"type": "custom",
"format": "╭──────────────╮"
},
{
"type": "uptime",
"key": "│ 󰅐 uptime │",
"keyColor": "cyan"
},
{
"type": "os",
"key": "│ 󰣇 distro │",
"keyColor": "green"
},
{
"type": "packages",
"key": "│ 󰏖 packages │",
"keyColor": "magenta"
},
{
"type": "terminal",
"key": "│ 󰞅 term │",
"keyColor": "red"
},
{
"type": "shell",
"key": "│ 󰞷 shell │",
"keyColor": "yellow"
},
{
"type": "custom",
"format": "├──────────────┤"
},
{
"type": "cpu",
"key": "│ % cpu load │",
"keyColor": "magenta",
"temp": false
},
{
"type": "memory",
"key": "│ 󰍛 memory │",
"keyColor": "red",
"format": "{1} / {2} ({3})"
},
{
"type": "disk",
"key": "│ 󰋊 SSD1 │",
"keyColor": "green",
"format": "{1} / {2} ({3})"
},
{
"type": "custom",
"format": "├──────────────┤"
},
{
"type": "colors",
"key": "│ 🎨 colors │",
"keyColor": "yellow",
"symbol": "circle"
},
{
"type": "custom",
"format": "╰──────────────╯"
}
]
}

View File

@ -15,8 +15,8 @@
"display": {
"separator": " ",
"color": {
"keys": "magenta",
"title": "bright_magenta"
"keys": "#a7c080",
"title": "#7fbbb3"
}
},
"modules": [
@ -77,7 +77,7 @@
},
{
"type": "colors",
"key": "│ 🎨 colors │",
"key": "│ 🎨 colors │",
"keyColor": "yellow",
"symbol": "circle"
},

View File

@ -1112,74 +1112,8 @@ theme[upload_end]="#ff80bf"
pass
def sync_fastfetch(bg, surface, current_line, fg, accent, sub_accent):
import re
fastfetch_dir = os.path.expanduser('~/.config/fastfetch')
os.makedirs(fastfetch_dir, exist_ok=True)
conf_path = os.path.join(fastfetch_dir, 'config.jsonc')
if os.path.exists(conf_path):
try:
with open(conf_path, 'r', encoding='utf-8') as f:
content = f.read()
modified = False
if '"keys"' in content:
content, count1 = re.subn(r'"keys"\s*:\s*"[^"]*"', f'"keys": "{accent}"', content)
if count1 > 0: modified = True
if '"title"' in content:
content, count2 = re.subn(r'"title"\s*:\s*"[^"]*"', f'"title": "{sub_accent}"', content)
if count2 > 0: modified = True
if not modified and '"display"' in content:
content = re.sub(r'"display"\s*:\s*\{', f'"display": {{\n "color": {{\n "keys": "{accent}",\n "title": "{sub_accent}"\n }},', content, count=1)
modified = True
if modified:
with open(conf_path, 'w', encoding='utf-8') as f:
f.write(content)
return
except Exception:
pass
fastfetch_jsonc = f"""{{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {{
"source": "~/.config/fastfetch/hamster_cookie.txt",
"padding": {{
"right": 4
}}
}},
"display": {{
"color": {{
"keys": "{accent}",
"title": "{sub_accent}"
}}
}},
"modules": [
"title",
"separator",
"os",
"host",
"kernel",
"uptime",
"packages",
"shell",
"display",
"wm",
"terminal",
"cpu",
"gpu",
"memory",
"break",
"colors"
]
}}
"""
try:
with open(conf_path, 'w', encoding='utf-8') as f:
f.write(fastfetch_jsonc)
except Exception:
pass
# Preserves user's exact master fastfetch configuration from ~/.config/fastfetch/
pass
def sync_ghostty(bg, surface, current_line, fg, accent, sub_accent):
ghostty_dir = os.path.expanduser('~/.config/ghostty')