fix: remove fastfetch overwriting from theme_sync.py and use ~/.config/fastfetch as reference
This commit is contained in:
parent
90634d2977
commit
b01a8cc752
@ -2,79 +2,88 @@
|
||||
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
|
||||
"logo": {
|
||||
"source": "~/.config/fastfetch/hamster_cookie.txt",
|
||||
"type": "file",
|
||||
"color": {
|
||||
"1": "magenta",
|
||||
"2": "yellow"
|
||||
},
|
||||
"padding": {
|
||||
"top": 0,
|
||||
"left": 1,
|
||||
"right": 3
|
||||
"top": 1,
|
||||
"left": 2,
|
||||
"right": 2
|
||||
}
|
||||
},
|
||||
"display": {
|
||||
"separator": " ➜ ",
|
||||
"separator": " ",
|
||||
"color": {
|
||||
"keys": "#a7c080",
|
||||
"title": "#7fbbb3"
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
"title",
|
||||
"separator",
|
||||
{
|
||||
"type": "os",
|
||||
"key": "OS",
|
||||
"keyColor": "cyan"
|
||||
},
|
||||
{
|
||||
"type": "host",
|
||||
"key": "Host",
|
||||
"keyColor": "green"
|
||||
},
|
||||
{
|
||||
"type": "kernel",
|
||||
"key": "Kernel",
|
||||
"keyColor": "yellow"
|
||||
"type": "custom",
|
||||
"format": "╭──────────────╮"
|
||||
},
|
||||
{
|
||||
"type": "uptime",
|
||||
"key": "Uptime",
|
||||
"keyColor": "blue"
|
||||
},
|
||||
{
|
||||
"type": "packages",
|
||||
"key": "Packages",
|
||||
"keyColor": "magenta"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"key": "Shell",
|
||||
"key": "│ uptime │",
|
||||
"keyColor": "cyan"
|
||||
},
|
||||
{
|
||||
"type": "terminal",
|
||||
"key": "Terminal",
|
||||
"type": "os",
|
||||
"key": "│ distro │",
|
||||
"keyColor": "green"
|
||||
},
|
||||
{
|
||||
"type": "wm",
|
||||
"key": "WM",
|
||||
"keyColor": "yellow"
|
||||
},
|
||||
{
|
||||
"type": "cpu",
|
||||
"key": "CPU",
|
||||
"keyColor": "blue"
|
||||
},
|
||||
{
|
||||
"type": "gpu",
|
||||
"key": "GPU",
|
||||
"type": "packages",
|
||||
"key": "│ packages │",
|
||||
"keyColor": "magenta"
|
||||
},
|
||||
{
|
||||
"type": "memory",
|
||||
"key": "Memory",
|
||||
"type": "terminal",
|
||||
"key": "│ term │",
|
||||
"keyColor": "red"
|
||||
},
|
||||
"break",
|
||||
"colors"
|
||||
{
|
||||
"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": "╰──────────────╯"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
"display": {
|
||||
"separator": " ",
|
||||
"color": {
|
||||
"keys": "magenta",
|
||||
"title": "bright_magenta"
|
||||
"keys": "#a7c080",
|
||||
"title": "#7fbbb3"
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
|
||||
@ -1112,73 +1112,7 @@ 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:
|
||||
# Preserves user's exact master fastfetch configuration from ~/.config/fastfetch/
|
||||
pass
|
||||
|
||||
def sync_ghostty(bg, surface, current_line, fg, accent, sub_accent):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user