chamesle

chamesle.org: the site of Chamesle, a small Linux distribution
git clone https://github.com/tortr-rs/chamesle
Log | Files | Refs | README

make.py (27097B)


      1 #!/usr/bin/env python3
      2 # chamesle glass icons: builds the icon theme from glossy parts
      3 # usage: make.py OUTDIR   (OUTDIR/Chamesle-Glass gets made)
      4 import os, sys, shutil
      5 
      6 HERE = os.path.dirname(os.path.abspath(__file__))
      7 
      8 def svg(body, defs=''):
      9 	return ('<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">\n'
     10 		'<defs>' + COMMON + defs + '</defs>\n' + body + '\n</svg>\n')
     11 
     12 def lin(id, *stops, x2=0, y2=1):
     13 	s = ''.join('<stop offset="%s" stop-color="%s"%s/>' % (o, c, '' if a is None else ' stop-opacity="%s"' % a)
     14 		for o, c, a in [(st + (None,))[:3] for st in stops])
     15 	return '<linearGradient id="%s" x1="0" y1="0" x2="%s" y2="%s">%s</linearGradient>' % (id, x2, y2, s)
     16 
     17 def rad(id, *stops, cx=.5, cy=.5, r=.5):
     18 	s = ''.join('<stop offset="%s" stop-color="%s"%s/>' % (o, c, '' if a is None else ' stop-opacity="%s"' % a)
     19 		for o, c, a in [(st + (None,))[:3] for st in stops])
     20 	return '<radialGradient id="%s" cx="%s" cy="%s" r="%s">%s</radialGradient>' % (id, cx, cy, r, s)
     21 
     22 COMMON = (rad('shadow', (0, '#000', .45), (1, '#000', 0)) +
     23 	lin('gloss', (0, '#fff', .85), (1, '#fff', .05)) +
     24 	lin('glossd', (0, '#fff', .55), (.55, '#fff', 0), x2=1) +
     25 	lin('paper', (0, '#ffffff'), (1, '#dde5ec')) +
     26 	lin('metal', (0, '#ffffff'), (.5, '#b9c1ca'), (1, '#6f7a86')) +
     27 	'<filter id="glow" x="-30%" y="-30%" width="160%" height="160%"><feGaussianBlur stdDeviation="2.5"/></filter>' +
     28 	'<filter id="soft"><feGaussianBlur stdDeviation="4"/></filter>')
     29 
     30 def shadow(cx=64, cy=114, rx=52, ry=7):
     31 	return '<ellipse cx="%d" cy="%d" rx="%d" ry="%d" fill="url(#shadow)"/>' % (cx, cy, rx, ry)
     32 
     33 # a white glyph with a dark edge, readable on any colour
     34 def glyph(d, edge='#0b3866', w=5, fill='none'):
     35 	return ('<path d="%s" fill="%s" stroke="%s" stroke-width="%g" stroke-linecap="round" stroke-linejoin="round"/>'
     36 		'<path d="%s" fill="%s" stroke="#fff" stroke-width="%g" stroke-linecap="round" stroke-linejoin="round"/>'
     37 		% (d, 'none' if fill == 'none' else edge, edge, w + 3, d, fill, w))
     38 
     39 # glossy bead, the base for round things
     40 def bead(c0, c1, c2, cx=64, cy=62, r=46, inner=''):
     41 	d = rad('b', (0, c0), (.55, c1), (1, c2), cy=.3, r=.75)
     42 	b = (shadow(cx, cy + r + 6, r, 7) +
     43 		'<circle cx="%d" cy="%d" r="%d" fill="url(#b)" stroke="#0d1a2a" stroke-opacity=".7" stroke-width="1.5"/>' % (cx, cy, r) +
     44 		inner +
     45 		'<ellipse cx="%d" cy="%d" rx="%d" ry="%d" fill="url(#gloss)" opacity=".8"/>' % (cx, cy - r * .48, r * .72, r * .4))
     46 	return b, d
     47 
     48 # folders
     49 
     50 FOLDER_BACK = '<path d="M12 26a6 6 0 0 1 6-6h30l8 8h56a6 6 0 0 1 6 6v68a6 6 0 0 1-6 6H18a6 6 0 0 1-6-6z" fill="url(#fb)" stroke="#0b3866" stroke-width="1.5"/>'
     51 FOLDER_FRONT = ('<path d="M8 52a6 6 0 0 1 6-6h100a6 6 0 0 1 6 6l-4 50a6 6 0 0 1-6 6H18a6 6 0 0 1-6-6z" fill="url(#ff)" stroke="#0b3866" stroke-width="1.5"/>'
     52 	'<path d="M11 52a4 4 0 0 1 4-4h98a4 4 0 0 1 4 4l-1.6 20c-34 7-68 7-103 0z" fill="url(#gloss)" opacity=".75"/>'
     53 	'<path d="M14 49h100" stroke="#fff" stroke-opacity=".9" stroke-width="1.5" stroke-linecap="round"/>')
     54 FOLDER_DEFS = (lin('fb', (0, '#3b9be0'), (1, '#11508f')) +
     55 	lin('ff', (0, '#8fdcff'), (.45, '#3fa8ee'), (1, '#1667b8')))
     56 PAPERS = ('<rect x="22" y="32" width="86" height="50" rx="3" fill="url(#paper)" stroke="#9aa9b6" transform="rotate(-4 64 57)"/>'
     57 	'<rect x="26" y="38" width="80" height="46" rx="3" fill="url(#paper)" stroke="#9aa9b6" transform="rotate(3 64 61)"/>')
     58 
     59 def folder(emblem='', papers=True, open=False):
     60 	front = FOLDER_FRONT
     61 	if open:
     62 		front = ('<path d="M4 58a6 6 0 0 1 6-6h104a6 6 0 0 1 6 7l-8 43a6 6 0 0 1-6 6H18a6 6 0 0 1-6-6z" fill="url(#ff)" stroke="#0b3866" stroke-width="1.5"/>'
     63 			'<path d="M7 58a4 4 0 0 1 4-4h102a4 4 0 0 1 4 4.5l-2.5 14c-34 7-70 7-104 0z" fill="url(#gloss)" opacity=".75"/>')
     64 	return svg(shadow(64, 114, 54, 8) + FOLDER_BACK + (PAPERS if papers else '') + front + emblem, FOLDER_DEFS)
     65 
     66 EMBLEMS = {
     67 	'documents': glyph('M54 66h14l8 8v26H54zM68 66v8h8M59 82h12M59 90h12'),
     68 	'download': glyph('M64 64v24M53 78l11 11 11-11M50 98h28'),
     69 	'music': glyph('M60 96V72l16-4v22', w=4.5) + '<circle cx="56" cy="96" r="5" fill="#fff" stroke="#0b3866" stroke-width="2"/><circle cx="72" cy="90" r="5" fill="#fff" stroke="#0b3866" stroke-width="2"/>',
     70 	'pictures': glyph('M48 68h32v28H48z') + '<path d="M51 93l9-10 6 6 4-4 8 8z" fill="#fff"/><circle cx="72" cy="75" r="3" fill="#fff"/>',
     71 	'videos': glyph('M58 70l18 12-18 12z', fill='#fff'),
     72 	'desktop': glyph('M48 68h32v20H48zM58 96h12M64 88v8'),
     73 	'templates': ('<path d="M52 64h18l8 8v28H52z" fill="none" stroke="#0b3866" stroke-width="7" stroke-linejoin="round"/>'
     74 		'<path d="M52 64h18l8 8v28H52z" fill="#fff" fill-opacity=".25" stroke="#fff" stroke-width="4" stroke-dasharray="6 4" stroke-linejoin="round"/>'
     75 		+ glyph('M64 76v14M57 83h14', w=4)),
     76 	'publicshare': glyph('M56 76a5 5 0 1 0 0.1 0M72 76a5 5 0 1 0 0.1 0M46 98c2-10 18-10 20 0M62 98c2-10 18-10 20 0'),
     77 	'remote': glyph('M64 66a16 16 0 1 0 0.1 0M48 82h32M64 66c7 6 7 26 0 32M64 66c-7 6-7 26 0 32', w=3.5),
     78 	'home': ('<path d="M46 78v22h36V78" fill="url(#wall)" stroke="#2b5d8a" stroke-width="1.5"/>'
     79 		'<rect x="58" y="86" width="12" height="14" rx="1.5" fill="#3a8fd6" stroke="#2b5d8a"/>'
     80 		'<path d="M40 80l24-20 24 20" fill="url(#roof)" stroke="#8c3a10" stroke-width="2" stroke-linejoin="round"/>'
     81 		'<path d="M44 76l20-16.5 20 16.5" fill="none" stroke="#fff" stroke-opacity=".6" stroke-width="1.5" stroke-linejoin="round"/>'),
     82 	'git': glyph('M56 64v34M56 88c0-12 16-8 16-20', w=4) + ''.join('<circle cx="%d" cy="%d" r="5" fill="#fff" stroke="#0b3866" stroke-width="2.5"/>' % p for p in [(56, 62), (56, 98), (72, 66)]),
     83 	'games': glyph('M50 76h28a8 8 0 0 1 8 8v4a6 6 0 0 1-11 3l-3-4H56l-3 4a6 6 0 0 1-11-3v-4a8 8 0 0 1 8-8zM56 80v8M52 84h8'),
     84 }
     85 HOME_DEFS = lin('roof', (0, '#ffb36b'), (1, '#d9601f')) + lin('wall', (0, '#ffffff'), (1, '#dfe9f2'))
     86 
     87 def emblem_folder(name):
     88 	s = folder(EMBLEMS[name], papers=False)
     89 	return s.replace('</defs>', HOME_DEFS + '</defs>') if name == 'home' else s
     90 
     91 # pages, for file types
     92 
     93 PAGE = ('<path d="M28 8h52l24 24v80a6 6 0 0 1-6 6H28a6 6 0 0 1-6-6V14a6 6 0 0 1 6-6z" fill="url(#paper)" stroke="#6f7c89" stroke-width="1.5"/>'
     94 	'<path d="M80 8v18a6 6 0 0 0 6 6h18" fill="#e6edf3" stroke="#6f7c89" stroke-width="1.5" stroke-linejoin="round"/>'
     95 	'<path d="M24 14a6 6 0 0 1 6-4h48v14C60 26 40 40 24 60z" fill="url(#glossd)" opacity=".7"/>')
     96 
     97 def lines(x0=34, x1=94, y0=44, n=7, gap=9, col='#8fa0b0'):
     98 	return ''.join('<path d="M%d %dh%d" stroke="%s" stroke-width="3" stroke-linecap="round"/>' % (x0, y0 + i * gap, (x1 - x0) - (14 if i % 3 == 2 else 0), col) for i in range(n))
     99 
    100 def band(c0, c1, label='', y=86):
    101 	d = lin('band', (0, c0), (.5, c1), (1, c0))
    102 	t = ('<text x="63" y="%d" text-anchor="middle" font-family="DejaVu Sans, sans-serif" font-weight="700" font-size="17" fill="#fff" stroke="#000" stroke-opacity=".25" stroke-width=".8">%s</text>' % (y + 18, label)) if label else ''
    103 	return ('<rect x="22" y="%d" width="82" height="26" fill="url(#band)" stroke="#000" stroke-opacity=".35"/>' % y +
    104 		'<rect x="22" y="%d" width="82" height="11" fill="#fff" opacity=".35"/>' % y + t), d
    105 
    106 def page(inner='', defs=''):
    107 	return svg(shadow(64, 118, 44, 6) + PAGE + inner, defs)
    108 
    109 def typed(label, c0, c1, inner=None):
    110 	b, d = band(c0, c1, label)
    111 	return page((lines(n=4) if inner is None else inner) + b, d)
    112 
    113 # pictures that go on pages or stand alone
    114 
    115 PHOTO_DEFS = (lin('sky', (0, '#2f9bf0'), (1, '#c8efff')) + lin('hill', (0, '#8fe35a'), (1, '#2f8a2a')) +
    116 	lin('hill2', (0, '#b7f07a'), (1, '#4fae36')) + rad('sun', (0, '#fffbe0'), (1, '#ffc21f'), cx=.4, cy=.4, r=.6))
    117 
    118 def photo(x, y, w, h):
    119 	return ('<clipPath id="pc"><rect x="%d" y="%d" width="%d" height="%d"/></clipPath>' % (x, y, w, h) +
    120 		'<g clip-path="url(#pc)"><rect x="%d" y="%d" width="%d" height="%d" fill="url(#sky)"/>' % (x, y, w, h) +
    121 		'<circle cx="%d" cy="%d" r="%d" fill="url(#sun)"/>' % (x + w * .75, y + h * .28, h * .15) +
    122 		'<path d="M%d %dc%d %d %d %d %d 0s%d %d %d %dv%dH%dz" fill="url(#hill2)"/>' % (x - 4, y + h * .76, w * .22, -h * .24, w * .45, -h * .2, w * .65, w * .38, h * .1, w * .45, -h * .03, h * .4, x - 4) +
    123 		'<path d="M%d %dc%d %d %d %d %d -3s%d 3 %d 0v%dH%dz" fill="url(#hill)"/>' % (x - 4, y + h * .9, w * .25, -h * .2, w * .55, -h * .2, w * .77, w * .27, w * .32, h * .3, x - 4) +
    124 		'</g><rect x="%d" y="%d" width="%d" height="%d" fill="none" stroke="#5d6873"/>' % (x, y, w, h))
    125 
    126 DISC_DEFS = rad('disc', (.2, '#f4f6f8'), (.9, '#c9d1d9'), (1, '#9aa5b0'))
    127 def disc(cx=64, cy=60, r=48):
    128 	return ('<clipPath id="dc"><circle cx="%d" cy="%d" r="%d"/></clipPath>' % (cx, cy, r) +
    129 		'<circle cx="%d" cy="%d" r="%d" fill="url(#disc)" stroke="#5d6873" stroke-width="1.5"/>' % (cx, cy, r) +
    130 		'<g clip-path="url(#dc)" filter="url(#soft)" opacity=".55" transform="translate(%d %d)">' % (cx - 64, cy - 60) +
    131 		'<path d="M64 60L24 10h32z" fill="#ff5fa2"/><path d="M64 60l48-30v28z" fill="#4fd0ff"/>'
    132 		'<path d="M64 60l42 48H78z" fill="#ffe15a"/><path d="M64 60L14 84V62z" fill="#7cff8a"/></g>' +
    133 		'<circle cx="%d" cy="%d" r="%d" fill="#e8edf2" fill-opacity=".8" stroke="#8a96a2"/>' % (cx, cy, r // 3) +
    134 		'<circle cx="%d" cy="%d" r="%d" fill="#fff" stroke="#6f7a86"/>' % (cx, cy, r // 8) +
    135 		'<path d="M%d %dc10-22 %d-26 %d-6" fill="none" stroke="#fff" stroke-opacity=".8" stroke-width="2" stroke-linecap="round"/>' % (cx - r * .78, cy - r * .42, r * 1.3, r * 1.6))
    136 
    137 def note_bubble(cx=92, cy=90, r=26):
    138 	return ('<circle cx="%d" cy="%d" r="%d" fill="url(#note)" stroke="#7d200c" stroke-width="1.5"/>' % (cx, cy, r) +
    139 		'<path d="M%d %dV%dl14-4v20" fill="none" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>' % (cx - 4, cy + 12, cy - 12) +
    140 		'<ellipse cx="%d" cy="%d" rx="5.5" ry="4.5" fill="#fff"/><ellipse cx="%d" cy="%d" rx="5.5" ry="4.5" fill="#fff"/>' % (cx - 8, cy + 12, cx + 6, cy + 6) +
    141 		'<ellipse cx="%d" cy="%d" rx="%d" ry="%d" fill="url(#gloss)" opacity=".75"/>' % (cx, cy - r * .55, r * .72, r * .38))
    142 NOTE_DEFS = lin('note', (0, '#ffb08a'), (.5, '#f0602e'), (1, '#b8361a'))
    143 
    144 def film(x, y, w, h):
    145 	holes = ''.join('<rect x="%d" y="%d" width="6" height="5" rx="1" fill="#e8edf2"/><rect x="%d" y="%d" width="6" height="5" rx="1" fill="#e8edf2"/>' % (x + 4 + i * 11, y + 3, x + 4 + i * 11, y + h - 8) for i in range(int((w - 4) // 11)))
    146 	return ('<rect x="%d" y="%d" width="%d" height="%d" rx="3" fill="url(#filmg)" stroke="#000"/>' % (x, y, w, h) + holes +
    147 		'<rect x="%d" y="%d" width="%d" height="%d" fill="url(#screen)"/>' % (x + 4, y + 11, w - 8, h - 22))
    148 FILM_DEFS = lin('filmg', (0, '#4a525c'), (1, '#0d0f12')) + lin('screen', (0, '#1f7fd6'), (.6, '#4fc3e8'), (1, '#bff0d0'))
    149 
    150 # the chamesle ring: three thick pieces with gaps, like the logo
    151 def ring(cx=64, cy=64, R=30, r=15):
    152 	import math
    153 	def pt(a, rr):
    154 		return cx + rr * math.cos(math.radians(a)), cy + rr * math.sin(math.radians(a))
    155 	def piece(a0, a1, col):
    156 		o0, o1, i0, i1 = pt(a0, R), pt(a1, R), pt(a0, r), pt(a1, r)
    157 		return ('<path d="M%.1f %.1fA%d %d 0 0 1 %.1f %.1fL%.1f %.1fA%d %d 0 0 0 %.1f %.1fz" fill="%s" stroke="#fff" stroke-width="1.2" stroke-linejoin="round"/>'
    158 			% (o0[0], o0[1], R, R, o1[0], o1[1], i1[0], i1[1], r, r, i0[0], i0[1], col))
    159 	return piece(-143, -37, '#00bf63') + piece(-27, 84, '#1a00a8') + piece(96, 207, '#ff3333')
    160 
    161 # hand-drawn ones live in parts/*.svg
    162 
    163 def part(name):
    164 	with open(os.path.join(HERE, 'parts', name + '.svg')) as f:
    165 		return f.read()
    166 
    167 # icons: name -> svg text
    168 
    169 ICONS = {}
    170 def add(cat, name, text):
    171 	ICONS[(cat, name)] = text
    172 
    173 def build():
    174 	add('places', 'folder', folder())
    175 	add('places', 'folder-open', folder(open=True))
    176 	for e in EMBLEMS:
    177 		add('places', 'folder-' + e, emblem_folder(e))
    178 	add('places', 'user-trash', part('bin'))
    179 	add('places', 'user-trash-full', part('bin-full'))
    180 	b, d = bead('#ffffff', '#e2f1fa', '#7fa9c8', inner=ring(64, 62, 32, 16))
    181 	add('places', 'start-here', svg(b, d))
    182 	b, d = bead('#bdf1ff', '#2f9be0', '#0f4f96', inner=glyph('M64 26a36 36 0 1 0 0.1 0M28 62h72M64 26c14 10 14 62 0 72M64 26c-14 10-14 62 0 72', w=3.5))
    183 	add('places', 'network-workgroup', svg(b, d))
    184 
    185 	add('devices', 'computer', part('pc'))
    186 	add('devices', 'drive-harddisk', part('drive'))
    187 	add('devices', 'drive-removable-media', part('usb'))
    188 	add('devices', 'media-optical', svg(shadow(64, 114, 50, 7) + disc(64, 60, 48), DISC_DEFS))
    189 	add('devices', 'media-flash', part('sdcard'))
    190 	add('devices', 'phone', part('phone'))
    191 	add('devices', 'printer', part('printer'))
    192 	add('devices', 'input-keyboard', part('keyboard'))
    193 	add('devices', 'input-mouse', part('mouse'))
    194 	add('devices', 'input-gaming', part('gamepad'))
    195 	add('devices', 'camera-photo', part('camera'))
    196 	add('devices', 'camera-web', part('webcam'))
    197 	add('devices', 'audio-headphones', part('headphones'))
    198 	add('devices', 'audio-speakers', part('speaker'))
    199 	add('devices', 'battery', part('battery'))
    200 	b, d = bead('#a8ecff', '#2f8de4', '#0f4f96', inner=glyph('M52 46l24 24-12 12V38l12 12-24 24', w=4.5))
    201 	add('devices', 'bluetooth', svg(b, d))
    202 	b, d = bead('#bdf1ff', '#2f9be0', '#0f4f96', inner=glyph('M36 56a40 40 0 0 1 56 0M44 66a28 28 0 0 1 40 0M53 76a14 14 0 0 1 22 0M64 86h.1', w=5))
    203 	add('devices', 'network-wireless', svg(b, d))
    204 	add('devices', 'network-wired', part('ethernet'))
    205 
    206 	add('mimetypes', 'text-x-generic', page(lines()))
    207 	add('mimetypes', 'text-x-script', page('<rect x="30" y="38" width="66" height="62" rx="3" fill="#0b1820"/>' +
    208 		'<path d="M38 50l8 6-8 6M50 64h14M38 76h40M38 86h28" stroke="#5cff86" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>'))
    209 	add('mimetypes', 'text-x-source', page(
    210 		'<path d="M46 52l-10 12 10 12M80 52l10 12-10 12M70 46l-14 36" stroke="#2f7fe0" stroke-width="5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>' + lines(y0=94, n=2)))
    211 	b, d = bead('#bdf1ff', '#2f9be0', '#0f4f96', cx=64, cy=72, r=26, inner=glyph('M64 46a26 26 0 1 0 0.1 0M38 72h52M64 46c10 7 10 45 0 52M64 46c-10 7-10 45 0 52', w=2.5))
    212 	add('mimetypes', 'text-html', page(lines(n=2) + b, d))
    213 	add('mimetypes', 'application-pdf', typed('PDF', '#e0452c', '#b8301c'))
    214 	add('mimetypes', 'image-x-generic', page(photo(32, 40, 62, 50), PHOTO_DEFS))
    215 	add('mimetypes', 'audio-x-generic', page(note_bubble(63, 70, 26), NOTE_DEFS))
    216 	add('mimetypes', 'video-x-generic', page(film(30, 46, 66, 48), FILM_DEFS))
    217 	add('mimetypes', 'package-x-generic', part('box'))
    218 	add('mimetypes', 'application-x-archive', part('zip'))
    219 	add('mimetypes', 'application-x-executable', page(
    220 		'<g transform="translate(26 32) scale(.58)">' + part('settings').split('</defs>')[1].replace('</svg>', '') + '</g>', rad('eye', (0, '#bff0ff'), (.55, '#2f8de4'), (1, '#0f4f96'), cy=.3, r=.75)))
    221 	add('mimetypes', 'application-x-cd-image', svg(shadow(64, 114, 50, 7) + disc(64, 60, 48) +
    222 		'<rect x="70" y="72" width="44" height="28" rx="4" fill="url(#ib)" stroke="#0b3866"/><text x="92" y="92" text-anchor="middle" font-family="DejaVu Sans, sans-serif" font-weight="700" font-size="15" fill="#fff">ISO</text>',
    223 		DISC_DEFS + lin('ib', (0, '#8fdcff'), (.5, '#2f8de4'), (1, '#1667b8'))))
    224 	add('mimetypes', 'font-x-generic', page('<text x="62" y="86" text-anchor="middle" font-family="DejaVu Serif, serif" font-size="46" fill="url(#ink)" stroke="#0b2c5a" stroke-width="1">Aa</text>', lin('ink', (0, '#5fb0ff'), (1, '#0f4f96'))))
    225 	add('mimetypes', 'x-office-document', typed('', '#3f8fe8', '#1d5fb4', lines(y0=40, n=5)))
    226 	add('mimetypes', 'x-office-spreadsheet', page(''.join(
    227 		'<rect x="%d" y="%d" width="15" height="9" fill="%s" stroke="#7fb58a"/>' % (32 + c * 16, 40 + r * 10, '#c9ecd0' if r == 0 else '#ffffff') for r in range(6) for c in range(4)) +
    228 		band('#55c060', '#2a9a3a')[0], band('#55c060', '#2a9a3a')[1]))
    229 	add('mimetypes', 'x-office-presentation', page(
    230 		'<rect x="32" y="40" width="62" height="42" fill="#fff4ea" stroke="#d98a4a"/><path d="M40 74V60M52 74V52M64 74V64M76 74V48" stroke="#f08a2e" stroke-width="7"/>' +
    231 		band('#f6a04a', '#d9601f')[0], band('#f6a04a', '#d9601f')[1]))
    232 
    233 	add('apps', 'files', part('files'))
    234 	add('apps', 'terminal', part('term'))
    235 	add('apps', 'store', part('store'))
    236 	add('apps', 'settings', part('settings'))
    237 	add('apps', 'music', part('music'))
    238 	add('apps', 'pictures', part('pics'))
    239 	for p in ['editor', 'viewer', 'calculator', 'screenshot', 'monitor', 'diskusage', 'partitions', 'video',
    240 			'updater', 'drivers', 'wine', 'installer', 'pkgimport', 'tweaks', 'help', 'keys', 'volume', 'clipboard', 'mail', 'calendar']:
    241 		add('apps', p, part(p))
    242 	b, d = bead('#bdf1ff', '#2f9be0', '#0f4f96', inner=glyph('M64 38h.1M58 52h6v34M56 86h16', w=6))
    243 	add('apps', 'info', svg(b, d))
    244 	add('apps', 'archive', part('zip'))
    245 	add('apps', 'display', part('pc'))
    246 	add('apps', 'power', part('battery'))
    247 	add('apps', 'bluetooth', ICONS[('devices', 'bluetooth')])
    248 	add('apps', 'network', ICONS[('devices', 'network-wireless')])
    249 	add('apps', 'printer', ICONS[('devices', 'printer')])
    250 	add('apps', 'menu', ICONS[('places', 'start-here')])
    251 
    252 # every name an app or file type looks for, pointing at one drawing
    253 ALIASES = {
    254 	('places', 'folder'): 'inode-directory folder-blue default-folder',
    255 	('places', 'folder-home'): 'user-home folder-home default-user-home',
    256 	('places', 'folder-desktop'): 'user-desktop',
    257 	('places', 'folder-download'): 'folder-downloads',
    258 	('places', 'folder-pictures'): 'folder-images',
    259 	('places', 'folder-videos'): 'folder-video folder-movies',
    260 	('places', 'folder-remote'): 'folder-network network-server',
    261 	('places', 'user-trash'): 'trash-empty user-trash-empty',
    262 	('places', 'user-trash-full'): 'trash-full',
    263 	('places', 'start-here'): 'start-here-kde distributor-logo chamesle xfce4-whiskermenu whiskermenu cinnamon-menu mate-menu',
    264 	('places', 'network-workgroup'): 'network-workgroup folder-network network',
    265 	('devices', 'computer'): 'computer-laptop video-display display preferences-desktop-display',
    266 	('devices', 'drive-harddisk'): 'drive-harddisk-system drive-harddisk-solidstate drive-multidisk',
    267 	('devices', 'drive-removable-media'): 'drive-removable-media-usb media-removable drive-removable-media-usb-pendrive',
    268 	('devices', 'media-optical'): 'drive-optical media-optical-cd media-optical-dvd',
    269 	('devices', 'phone'): 'smartphone phone-android',
    270 	('devices', 'input-gaming'): 'applications-games',
    271 	('devices', 'camera-photo'): 'camera',
    272 	('devices', 'battery'): 'battery-full',
    273 	('devices', 'network-wireless'): 'network-wireless-connected',
    274 	('mimetypes', 'text-x-generic'): 'text-plain text-x-readme text-x-log text-x-markdown',
    275 	('mimetypes', 'text-x-script'): 'application-x-shellscript text-x-sh application-x-perl text-x-python text-x-python3',
    276 	('mimetypes', 'text-x-source'): 'text-x-c text-x-csrc text-x-chdr text-x-c++src text-x-rust text-x-go text-x-java application-javascript text-javascript application-json text-css text-x-makefile',
    277 	('mimetypes', 'text-html'): 'application-xhtml+xml text-xml application-xml',
    278 	('mimetypes', 'image-x-generic'): 'image-png image-jpeg image-gif image-webp image-bmp image-tiff image-svg+xml image-x-xcf image-heif image-avif',
    279 	('mimetypes', 'audio-x-generic'): 'audio-mpeg audio-x-flac audio-flac audio-ogg audio-x-vorbis+ogg audio-x-wav audio-mp4 audio-x-opus+ogg audio-aac',
    280 	('mimetypes', 'video-x-generic'): 'video-mp4 video-x-matroska video-webm video-x-msvideo video-quicktime video-mpeg video-ogg',
    281 	('mimetypes', 'package-x-generic'): 'application-x-apk application-vnd.debian.binary-package application-x-deb application-x-rpm application-x-redhat-package-manager application-vnd.flatpak application-vnd.flatpak.ref application-x-flatpak',
    282 	('mimetypes', 'application-x-archive'): 'application-zip application-x-tar application-x-compressed-tar application-x-xz-compressed-tar application-x-zstd-compressed-tar application-x-bzip-compressed-tar application-gzip application-x-gzip application-x-xz application-x-zstd application-x-7z-compressed application-x-rar application-vnd.rar',
    283 	('mimetypes', 'application-x-executable'): 'application-x-sharedlib application-x-object application-x-msdownload application-x-ms-dos-executable application-x-desktop',
    284 	('mimetypes', 'application-x-cd-image'): 'application-x-iso9660-image application-x-raw-disk-image',
    285 	('mimetypes', 'font-x-generic'): 'font-ttf font-otf application-x-font-ttf font-woff',
    286 	('mimetypes', 'x-office-document'): 'application-vnd.oasis.opendocument.text application-msword application-vnd.openxmlformats-officedocument.wordprocessingml.document application-rtf text-rtf',
    287 	('mimetypes', 'x-office-spreadsheet'): 'application-vnd.oasis.opendocument.spreadsheet application-vnd.ms-excel application-vnd.openxmlformats-officedocument.spreadsheetml.sheet text-csv',
    288 	('mimetypes', 'x-office-presentation'): 'application-vnd.oasis.opendocument.presentation application-vnd.ms-powerpoint application-vnd.openxmlformats-officedocument.presentationml.presentation',
    289 	('apps', 'files'): 'system-file-manager org.kde.dolphin dolphin org.xfce.thunar thunar Thunar org.gnome.Nautilus nautilus nemo caja file-manager',
    290 	('apps', 'terminal'): 'utilities-terminal org.kde.konsole konsole org.xfce.terminal xfce4-terminal org.gnome.Console org.gnome.Terminal gnome-terminal mate-terminal terminal xterm',
    291 	('apps', 'store'): 'system-software-install org.chamesle.Store chamesle-store plasmadiscover org.kde.discover flatpak-discover org.gnome.Software gnome-software',
    292 	('apps', 'settings'): 'preferences-system systemsettings org.kde.systemsettings org.gnome.Settings gnome-control-center org.xfce.settings.manager xfce4-settings-manager mate-control-center cinnamon-settings preferences-desktop',
    293 	('apps', 'music'): 'org.kde.elisa elisa multimedia-audio-player audio-player rhythmbox',
    294 	('apps', 'pictures'): 'org.kde.gwenview gwenview org.xfce.ristretto ristretto org.gnome.Loupe org.gnome.eog eog eom image-viewer multimedia-photo-viewer',
    295 	('apps', 'editor'): 'accessories-text-editor org.kde.kate kate org.xfce.mousepad mousepad org.gnome.TextEditor gnome-text-editor xed pluma text-editor',
    296 	('apps', 'viewer'): 'org.kde.okular okular org.gnome.Evince evince org.gnome.Papers xreader atril document-viewer x-office-document-viewer',
    297 	('apps', 'calculator'): 'accessories-calculator org.kde.kcalc kcalc org.gnome.Calculator gnome-calculator mate-calc galculator',
    298 	('apps', 'screenshot'): 'applets-screenshooter org.kde.spectacle spectacle org.xfce.screenshooter xfce4-screenshooter org.gnome.Screenshot gnome-screenshot accessories-screenshot',
    299 	('apps', 'monitor'): 'utilities-system-monitor org.kde.plasma-systemmonitor plasma-systemmonitor ksysguard org.gnome.SystemMonitor gnome-system-monitor mate-system-monitor org.xfce.taskmanager xfce4-taskmanager',
    300 	('apps', 'diskusage'): 'org.kde.filelight filelight baobab org.gnome.baobab',
    301 	('apps', 'partitions'): 'partitionmanager org.kde.partitionmanager gparted org.gnome.DiskUtility gnome-disks drive-harddisk-system',
    302 	('apps', 'video'): 'io.github.celluloid_player.Celluloid celluloid multimedia-video-player totem vlc mpv',
    303 	('apps', 'updater'): 'chamesle-updater system-software-update software-update-available update-manager',
    304 	('apps', 'drivers'): 'chamesle-drivers jockey',
    305 	('apps', 'wine'): 'chamesle-wine wine wine-config',
    306 	('apps', 'installer'): 'jiggity system-installer live-installer calamares',
    307 	('apps', 'pkgimport'): 'pkgimport pkgimport-gui application-x-deb-import',
    308 	('apps', 'tweaks'): 'org.gnome.tweaks gnome-tweak-tool preferences-desktop-tweaks',
    309 	('apps', 'help'): 'help-browser help-contents org.kde.khelpcenter yelp org.gnome.Yelp',
    310 	('apps', 'keys'): 'kwalletmanager org.kde.kwalletmanager seahorse org.gnome.seahorse.Application dialog-password',
    311 	('apps', 'volume'): 'multimedia-volume-control pavucontrol org.pulseaudio.pavucontrol audio-volume-high preferences-desktop-sound',
    312 	('apps', 'clipboard'): 'xfce4-clipman-plugin clipman edit-paste klipper',
    313 	('apps', 'mail'): 'internet-mail thunderbird mail-client',
    314 	('apps', 'calendar'): 'office-calendar org.gnome.Calendar',
    315 	('apps', 'info'): 'kinfocenter org.kde.kinfocenter dialog-information hwinfo',
    316 	('apps', 'archive'): 'org.kde.ark ark xarchiver org.gnome.FileRoller file-roller engrampa utilities-file-archiver',
    317 	('apps', 'display'): 'preferences-desktop-display kscreen kgamma',
    318 	('apps', 'power'): 'org.xfce.powermanager xfce4-power-manager mate-power-manager preferences-system-power',
    319 	('apps', 'bluetooth'): 'blueman bluedevil preferences-system-bluetooth',
    320 	('apps', 'network'): 'nm-applet network-manager preferences-system-network',
    321 	('apps', 'printer'): 'system-config-printer printer-settings',
    322 	('apps', 'menu'): 'kmenuedit alacarte menulibre',
    323 }
    324 
    325 INDEX = '''[Icon Theme]
    326 Name=Chamesle Glass
    327 Comment=Oxygen with Chamesle's own icons on top
    328 Inherits=oxygen,breeze,Adwaita,hicolor
    329 Example=folder
    330 Directories=scalable/apps,scalable/places,scalable/devices,scalable/mimetypes,256/apps,16x16/places,22x22/places,24x24/places,32x32/places,48x48/places,64x64/places
    331 
    332 [16x16/places]
    333 Size=16
    334 Context=Places
    335 Type=Fixed
    336 
    337 [22x22/places]
    338 Size=22
    339 Context=Places
    340 Type=Fixed
    341 
    342 [24x24/places]
    343 Size=24
    344 Context=Places
    345 Type=Fixed
    346 
    347 [32x32/places]
    348 Size=32
    349 Context=Places
    350 Type=Fixed
    351 
    352 [48x48/places]
    353 Size=48
    354 Context=Places
    355 Type=Fixed
    356 
    357 [64x64/places]
    358 Size=64
    359 Context=Places
    360 Type=Fixed
    361 
    362 [scalable/apps]
    363 Size=128
    364 MinSize=16
    365 MaxSize=512
    366 Type=Scalable
    367 Context=Applications
    368 
    369 [scalable/places]
    370 Size=128
    371 MinSize=16
    372 MaxSize=512
    373 Type=Scalable
    374 Context=Places
    375 
    376 [scalable/devices]
    377 Size=128
    378 MinSize=16
    379 MaxSize=512
    380 Type=Scalable
    381 Context=Devices
    382 
    383 [scalable/mimetypes]
    384 Size=128
    385 MinSize=16
    386 MaxSize=512
    387 Type=Scalable
    388 Context=MimeTypes
    389 
    390 [256/apps]
    391 Size=256
    392 MinSize=16
    393 MaxSize=512
    394 Type=Scalable
    395 Context=Applications
    396 '''
    397 
    398 # oxygen draws everything else, these are ours
    399 OURS = {('places', 'start-here'), ('apps', 'store'), ('apps', 'updater'), ('apps', 'drivers'),
    400 	('apps', 'wine'), ('apps', 'installer'), ('apps', 'pkgimport')}
    401 
    402 def main(out):
    403 	build()
    404 	for k in list(ICONS):
    405 		if k not in OURS:
    406 			del ICONS[k]
    407 	for k in list(ALIASES):
    408 		if k not in OURS:
    409 			del ALIASES[k]
    410 	root = os.path.join(out, 'Chamesle-Glass')
    411 	shutil.rmtree(root, ignore_errors=True)
    412 	for (cat, name), text in ICONS.items():
    413 		d = os.path.join(root, 'scalable', cat)
    414 		os.makedirs(d, exist_ok=True)
    415 		with open(os.path.join(d, name + '.svg'), 'w') as f:
    416 			f.write(text)
    417 	# the 2007 firefox logo, mozilla's own, under the mpl
    418 	os.makedirs(os.path.join(root, '256', 'apps'), exist_ok=True)
    419 	shutil.copy(os.path.join(HERE, 'firefox.png'), os.path.join(root, '256', 'apps', 'firefox.png'))
    420 	# cinnamon paints any svg named -symbolic white, so its menu gets the orb as pngs
    421 	for n in os.listdir(os.path.join(HERE, 'orb')):
    422 		d = os.path.join(root, '%sx%s' % (n[:-4], n[:-4]), 'places')
    423 		os.makedirs(d, exist_ok=True)
    424 		shutil.copy(os.path.join(HERE, 'orb', n), os.path.join(d, 'cinnamon-symbolic.png'))
    425 	for (cat, name), names in ALIASES.items():
    426 		for n in names.split():
    427 			p = os.path.join(root, 'scalable', cat, n + '.svg')
    428 			if not os.path.lexists(p):
    429 				os.symlink(name + '.svg', p)
    430 	with open(os.path.join(root, 'index.theme'), 'w') as f:
    431 		f.write(INDEX)
    432 	print(len(ICONS), 'drawings,', sum(len(v.split()) for v in ALIASES.values()), 'names')
    433 
    434 if __name__ == '__main__':
    435 	main(sys.argv[1] if len(sys.argv) > 1 else '.')