Something went wrong. Try again.
Getǣl — Read-only macOS home directory disk usage cartography & APFS telemetry service
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309#!/usr/bin/env python3"""Generate Getǣl's Astrolabe app and tray/menubar icons with zero dependencies.
Draws Getǣl's Astrolabe mark (matching `AstrolabeMark` in`web/src/components/Bezel.tsx`) using analytical signed-distance-fieldanti-aliasing and writes: - icons/icon.svg - icons/32x32.png - icons/128x128.png - icons/128x128@2x.png (256x256) - icons/icon.png (512x512) - icons/icon.ico (16, 32, 48, 256 PNG-in-ICO) - icons/icon.icns (macOS, via `iconutil`) - icons/tray-template.png (44x44 monochrome black+alpha template for macOS menubar) - icons/tray-color.png (44x44 colored Astrolabe for Windows/Linux system trays)
Run from the repository root:
python3 scripts/make_icons.py"""
from __future__ import annotations
import mathimport osimport shutilimport structimport subprocessimport sysimport zlib
# DESIGN.md paletteBG = (10, 11, 13) # #0A0B0D obsidian groundBEZEL = (36, 41, 51) # #242933 subtle bezel borderFG = (236, 238, 242) # #ECEEF2 instrument ivoryAMBER = (229, 154, 43) # #E59A2B Kaprekar amberBLACK = (0, 0, 0)
ICON_SVG = """<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="512" height="512"> <rect x="2" y="2" width="60" height="60" rx="14" fill="#0A0B0D" stroke="#242933" stroke-width="1.5" /> <g transform="translate(8 8) scale(2)" fill="none" stroke="#ECEEF2" stroke-width="1.5"> <circle cx="12" cy="12" r="9.5" stroke-opacity="0.85" /> <circle cx="12" cy="12" r="5.5" stroke-opacity="0.5" /> <circle cx="12" cy="12" r="1.5" fill="#E59A2B" stroke="none" /> <path d="M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" stroke-opacity="0.6" stroke-linecap="round" /> <path d="M15.8 8.2l-2.4 2.4" stroke="#E59A2B" stroke-linecap="round" /> </g></svg>"""
def clamp(v: float, lo: float = 0.0, hi: float = 1.0) -> float: return lo if v < lo else hi if v > hi else v
def sdf_rounded_rect(x: float, y: float, x0: float, y0: float, x1: float, y1: float, r: float) -> float: cx = (x0 + x1) * 0.5 cy = (y0 + y1) * 0.5 hx = (x1 - x0) * 0.5 - r hy = (y1 - y0) * 0.5 - r qx = abs(x - cx) - hx qy = abs(y - cy) - hy return math.hypot(max(qx, 0.0), max(qy, 0.0)) + min(max(qx, qy), 0.0) - r
def sdf_segment(x: float, y: float, ax: float, ay: float, bx: float, by: float) -> float: dx = bx - ax dy = by - ay denom = dx * dx + dy * dy t = clamp(((x - ax) * dx + (y - ay) * dy) / denom) if denom > 0.0 else 0.0 return math.hypot(x - (ax + t * dx), y - (ay + t * dy))
def over( dst_r: float, dst_g: float, dst_b: float, dst_a: float, src_rgb: tuple[int, int, int], src_a: float,) -> tuple[float, float, float, float]: if src_a <= 0.0: return dst_r, dst_g, dst_b, dst_a out_a = src_a + dst_a * (1.0 - src_a) if out_a <= 0.0: return 0.0, 0.0, 0.0, 0.0 inv = (1.0 - src_a) * dst_a out_r = (src_rgb[0] * src_a + dst_r * inv) / out_a out_g = (src_rgb[1] * src_a + dst_g * inv) / out_a out_b = (src_rgb[2] * src_a + dst_b * inv) / out_a return out_r, out_g, out_b, out_a
def draw_app_icon(size: int) -> bytes: """Render the full Astrolabe app icon on a rounded obsidian tile.""" # Coordinate space: 64x64 tile, with the 24x24 Astrolabe centered in [8..56]. scale = 64.0 / size aa = scale * 1.15 # Astrolabe coordinates mapped from 24x24 -> 64x64 via (v * 2 + 8) stroke_half = 1.5 # 1.5 in 24px space * 2 / 2 = 1.5 in 64px space center = 32.0 outer_r = 19.0 inner_r = 11.0 dot_r = 3.2 ticks = ( (32.0, 13.0, 32.0, 19.0), (32.0, 45.0, 32.0, 51.0), (13.0, 32.0, 19.0, 32.0), (45.0, 32.0, 51.0, 32.0), ) needle = (39.6, 24.4, 34.8, 29.2)
rows: list[bytes] = [] for py in range(size): row = bytearray([0]) # PNG filter byte = None y = (py + 0.5) * scale for px in range(size): x = (px + 0.5) * scale r = g = b = a = 0.0
# Rounded obsidian background tile d_tile = sdf_rounded_rect(x, y, 2.0, 2.0, 62.0, 62.0, 14.0) tile_cov = clamp(0.5 - d_tile / aa) if tile_cov > 0.0: r, g, b, a = over(r, g, b, a, BG, tile_cov)
# Subtle bezel stroke along the tile rim d_rim = abs(d_tile + 0.75) - 0.75 rim_cov = clamp(0.5 - d_rim / aa) if rim_cov > 0.0: r, g, b, a = over(r, g, b, a, BEZEL, rim_cov * 0.9)
dist_c = math.hypot(x - center, y - center)
# Outer ring (85% opacity) cov = clamp(0.5 - (abs(dist_c - outer_r) - stroke_half) / aa) if cov > 0.0: r, g, b, a = over(r, g, b, a, FG, cov * 0.85)
# Inner ring (50% opacity) cov = clamp(0.5 - (abs(dist_c - inner_r) - stroke_half) / aa) if cov > 0.0: r, g, b, a = over(r, g, b, a, FG, cov * 0.50)
# Cardinal ticks (60% opacity) d_tick = min(sdf_segment(x, y, ax, ay, bx, by) for ax, ay, bx, by in ticks) cov = clamp(0.5 - (d_tick - stroke_half) / aa) if cov > 0.0: r, g, b, a = over(r, g, b, a, FG, cov * 0.60)
# Amber needle d_needle = sdf_segment(x, y, *needle) cov = clamp(0.5 - (d_needle - stroke_half) / aa) if cov > 0.0: r, g, b, a = over(r, g, b, a, AMBER, cov)
# Amber center dot cov = clamp(0.5 - (dist_c - dot_r) / aa) if cov > 0.0: r, g, b, a = over(r, g, b, a, AMBER, cov)
row.append(int(round(r))) row.append(int(round(g))) row.append(int(round(b))) row.append(int(round(a * 255.0))) rows.append(bytes(row)) return b"".join(rows)
def draw_tray_icon(size: int, template: bool) -> bytes: """Render the transparent-background Astrolabe icon for menubar / system tray.
When `template=True`, draws in black + alpha only so macOS tints the menubar icon automatically for light and dark menu bars. """ scale = 24.0 / size aa = scale * 1.15 stroke_half = 0.95 # Slightly bolder than 0.75 so it stays crisp at 22pt center = 12.0 outer_r = 9.3 inner_r = 5.4 dot_r = 1.75 ticks = ( (12.0, 2.7, 12.0, 5.6), (12.0, 18.4, 12.0, 21.3), (2.7, 12.0, 5.6, 12.0), (18.4, 12.0, 21.3, 12.0), ) needle = (15.8, 8.2, 13.4, 10.6)
ring_rgb = BLACK if template else FG accent_rgb = BLACK if template else AMBER
rows: list[bytes] = [] for py in range(size): row = bytearray([0]) y = (py + 0.5) * scale for px in range(size): x = (px + 0.5) * scale r = g = b = a = 0.0 dist_c = math.hypot(x - center, y - center)
cov = clamp(0.5 - (abs(dist_c - outer_r) - stroke_half) / aa) if cov > 0.0: r, g, b, a = over(r, g, b, a, ring_rgb, cov * (0.95 if template else 0.90))
cov = clamp(0.5 - (abs(dist_c - inner_r) - stroke_half * 0.85) / aa) if cov > 0.0: r, g, b, a = over(r, g, b, a, ring_rgb, cov * (0.55 if template else 0.60))
d_tick = min(sdf_segment(x, y, ax, ay, bx, by) for ax, ay, bx, by in ticks) cov = clamp(0.5 - (d_tick - stroke_half * 0.85) / aa) if cov > 0.0: r, g, b, a = over(r, g, b, a, ring_rgb, cov * (0.75 if template else 0.70))
d_needle = sdf_segment(x, y, *needle) cov = clamp(0.5 - (d_needle - stroke_half) / aa) if cov > 0.0: r, g, b, a = over(r, g, b, a, accent_rgb, cov)
cov = clamp(0.5 - (dist_c - dot_r) / aa) if cov > 0.0: r, g, b, a = over(r, g, b, a, accent_rgb, cov)
row.append(int(round(r))) row.append(int(round(g))) row.append(int(round(b))) row.append(int(round(a * 255.0))) rows.append(bytes(row)) return b"".join(rows)
def png_chunk(kind: bytes, data: bytes) -> bytes: body = kind + data return struct.pack(">I", len(data)) + body + struct.pack(">I", zlib.crc32(body) & 0xFFFFFFFF)
def encode_png(size: int, raw_scanlines: bytes) -> bytes: ihdr = struct.pack(">IIBBBBB", size, size, 8, 6, 0, 0, 0) return ( b"\x89PNG\r\n\x1a\n" + png_chunk(b"IHDR", ihdr) + png_chunk(b"IDAT", zlib.compress(raw_scanlines, 9)) + png_chunk(b"IEND", b"") )
def encode_ico(images: list[tuple[int, bytes]]) -> bytes: """ICO container holding PNG-compressed images: [(size, png_bytes)].""" out = struct.pack("<HHH", 0, 1, len(images)) offset = 6 + 16 * len(images) for size, data in images: dim = 0 if size >= 256 else size out += struct.pack("<BBBBHHII", dim, dim, 0, 0, 1, 32, len(data), offset) offset += len(data) return out + b"".join(data for _, data in images)
def main() -> None: os.makedirs("icons", exist_ok=True) cache: dict[int, bytes] = {}
def app_png(size: int) -> bytes: if size not in cache: cache[size] = encode_png(size, draw_app_icon(size)) return cache[size]
with open("icons/icon.svg", "w", encoding="utf-8") as f: f.write(ICON_SVG)
for name, size in [ ("32x32.png", 32), ("128x128.png", 128), ("128x128@2x.png", 256), ("icon.png", 512), ]: with open(os.path.join("icons", name), "wb") as f: f.write(app_png(size))
with open("icons/icon.ico", "wb") as f: f.write(encode_ico([(s, app_png(s)) for s in (16, 32, 48, 256)]))
# Menubar / system tray icons (44x44 = 22pt @2x) with open("icons/tray-template.png", "wb") as f: f.write(encode_png(44, draw_tray_icon(44, template=True)))
with open("icons/tray-color.png", "wb") as f: f.write(encode_png(44, draw_tray_icon(44, template=False)))
if sys.platform == "darwin" and shutil.which("iconutil"): iconset = "icons/icon.iconset" if os.path.exists(iconset): shutil.rmtree(iconset) os.makedirs(iconset, exist_ok=True) for pts in (16, 32, 128, 256, 512): for scale in (1, 2): suffix = "" if scale == 1 else "@2x" with open(f"{iconset}/icon_{pts}x{pts}{suffix}.png", "wb") as f: f.write(app_png(pts * scale)) subprocess.run( ["iconutil", "-c", "icns", iconset, "-o", "icons/icon.icns"], check=True, ) shutil.rmtree(iconset)
if __name__ == "__main__": main()