refactor(fastfetch): merge the mac and kde configs into common
One Fastfetch package now serves both platforms. The logo is sent inline through the kitty graphics protocol from a pre-encoded albedo.kitty, which works in Ghostty and Kwi alike, so the separate kitty-direct (mac) and Konsole (kde) variants are no longer needed.
This commit is contained in:
1 parent
84e96f175c
commit
fa77bc2514
15 files changed
+62
-183
No files matched your search
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Encode albedo.png as kitty graphics escapes for fastfetch's "raw" logo.
|
||||
|
||||
fastfetch's "kitty-direct" logo sends the terminal a file path (t=f), which
|
||||
Kwi ignores. This file carries the PNG inline (t=d) instead, so it works in
|
||||
any terminal with the kitty graphics protocol, Ghostty and Kwi included. q=2
|
||||
keeps the terminal from answering. Rerun after changing the image or the
|
||||
logo size.
|
||||
"""
|
||||
|
||||
import base64
|
||||
from pathlib import Path
|
||||
|
||||
DIR = Path(__file__).resolve().parent / ".config/fastfetch"
|
||||
# Logo size in cells; keep in sync with "width" and "height" in config.jsonc.
|
||||
COLS, ROWS = 20, 10
|
||||
|
||||
|
||||
def encode(png: bytes) -> bytes:
|
||||
data = base64.b64encode(png)
|
||||
chunks = [data[i : i + 4096] for i in range(0, len(data), 4096)]
|
||||
out = bytearray()
|
||||
for n, chunk in enumerate(chunks):
|
||||
more = int(n < len(chunks) - 1)
|
||||
if n == 0:
|
||||
keys = b"a=T,f=100,t=d,c=%d,r=%d,q=2,m=%d" % (COLS, ROWS, more)
|
||||
else:
|
||||
keys = b"m=%d" % more
|
||||
out += b"\x1b_G" + keys + b";" + chunk + b"\x1b\\"
|
||||
return bytes(out)
|
||||
|
||||
|
||||
(DIR / "albedo.kitty").write_bytes(encode((DIR / "albedo.png").read_bytes()))
|
||||
Reference in new issue
Block a user