net-tools/tray/generate_icons.py
Natalie 57d51a7d4f feat(@tools/net-tools): add icon generation tool
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-06-10 05:35:11 -07:00

54 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Generate the net-tools menu-bar icons: a hub-and-spoke mesh glyph.
The glyph mirrors the actual wg1 topology — one hub (yuzu) linked to three
nodes, with faint node-to-node arcs so it reads as a mesh rather than a star.
Color encodes tunnel state (green = up, yellow = connecting, red = down),
the scheme the tray has always used. Output names are fixed API for
tray/vpn_tray.py.
"""
from pathlib import Path
import cairosvg
COLORS = {
"green": "#00FF88",
"red": "#FF3C3C",
"yellow": "#FFC800",
}
TEMPLATE = """<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<g stroke="{color}" stroke-width="1.7" stroke-linecap="round">
<line x1="12" y1="12.5" x2="12" y2="4.5"/>
<line x1="12" y1="12.5" x2="4.8" y2="18.6"/>
<line x1="12" y1="12.5" x2="19.2" y2="18.6"/>
</g>
<g stroke="{color}" stroke-width="1.1" stroke-linecap="round" opacity="0.45">
<line x1="4.8" y1="18.6" x2="19.2" y2="18.6"/>
<line x1="12" y1="4.5" x2="4.8" y2="18.6"/>
<line x1="12" y1="4.5" x2="19.2" y2="18.6"/>
</g>
<g fill="{color}">
<circle cx="12" cy="12.5" r="3.1"/>
<circle cx="12" cy="4.5" r="2.2"/>
<circle cx="4.8" cy="18.6" r="2.2"/>
<circle cx="19.2" cy="18.6" r="2.2"/>
</g>
</svg>"""
icons_dir = Path(__file__).parent / "icons"
for name, color in COLORS.items():
svg = TEMPLATE.format(color=color)
for size, suffix in [(18, ""), (36, "@2x")]:
out = icons_dir / f"vpn-{name}-18{suffix}.png"
cairosvg.svg2png(
bytestring=svg.encode(),
write_to=str(out),
output_width=size,
output_height=size,
)
print(f"Generated: {out.name}")
print("Done!")