make.py (29862B)
1 #!/usr/bin/env python3 2 # chamesle gray: window frames and panels for every desktop, the way workstations looked around 2001. 3 # black title bar on the window you're in, dark gray on the others, gray buttons raised one pixel, 4 # a thin black line round the window and a gray bar along the bottom to resize it by. 5 # nothing here is copied from anyone's theme, it's all drawn below. 6 # make.py SHARE writes SHARE/themes, SHARE/aurorae, SHARE/plasma, SHARE/color-schemes 7 import os, sys 8 from PIL import Image, ImageDraw 9 10 NAME = 'Chamesle-Gray' 11 TH = 22 # title bar height, the black line on top included 12 B = 1 # sides: just the black line 13 BB = 7 # the bar along the bottom 14 GRIP = 28 # its corner pieces, which resize both ways 15 BS = 16 # buttons are this square 16 BP = 3 # and sit this far in from their slot's edges 17 18 BLACK = (0, 0, 0) 19 WHITE = (255, 255, 255) 20 FACE = (174, 174, 174) # the gray everything's made of 21 LIGHT = (222, 222, 222) 22 DARK = (85, 85, 85) 23 TITLE = {True: (0, 0, 0), False: (76, 76, 76)} 24 TITLE_HI = {True: (52, 52, 52), False: (110, 110, 110)} 25 TEXT = {True: '#ffffff', False: '#c8c8c8'} 26 27 def hexc(c): 28 return '#%02x%02x%02x' % c 29 30 def save(im, *p): 31 f = os.path.join(*p) 32 os.makedirs(os.path.dirname(f), exist_ok=True) 33 im.save(f) 34 35 def save_text(text, *p): 36 f = os.path.join(*p) 37 os.makedirs(os.path.dirname(f), exist_ok=True) 38 open(f, 'w').write(text) 39 40 # a raised box: white on the top and left, dark then black on the bottom and right. pressed is the other way round 41 def bevel(d, x0, y0, x1, y1, face, pressed=False): 42 d.rectangle((x0, y0, x1, y1), fill=face) 43 hi, lo, edge = (DARK, LIGHT, WHITE) if pressed else (WHITE, DARK, BLACK) 44 if pressed: 45 d.line((x0, y0, x1, y0), fill=BLACK); d.line((x0, y0, x0, y1), fill=BLACK) 46 d.line((x0 + 1, y0 + 1, x1 - 1, y0 + 1), fill=DARK); d.line((x0 + 1, y0 + 1, x0 + 1, y1 - 1), fill=DARK) 47 d.line((x0, y1, x1, y1), fill=WHITE); d.line((x1, y0, x1, y1), fill=WHITE) 48 else: 49 d.line((x0, y0, x1, y0), fill=WHITE); d.line((x0, y0, x0, y1), fill=WHITE) 50 d.line((x0, y1, x1, y1), fill=BLACK); d.line((x1, y0, x1, y1), fill=BLACK) 51 d.line((x0 + 1, y1 - 1, x1 - 1, y1 - 1), fill=DARK); d.line((x1 - 1, y0 + 1, x1 - 1, y1 - 1), fill=DARK) 52 53 # the little pictures on the buttons, in black, inside a box at x, y of size s 54 def glyph(d, kind, x, y, s, col=BLACK): 55 m = s // 4 56 if kind == 'close': 57 for k in (0, 1): 58 d.line((x + m + k, y + m, x + s - m - 1 + k - 1, y + s - m - 1), fill=col) 59 d.line((x + m + k, y + s - m - 1, x + s - m - 1 + k - 1, y + m), fill=col) 60 elif kind == 'hide': 61 d.rectangle((x + m, y + s - m - 3, x + s - m - 1, y + s - m - 1), outline=col) 62 elif kind == 'maximize': 63 d.rectangle((x + m, y + m, x + s - m - 1, y + s - m - 1), outline=col) 64 d.line((x + m, y + m + 1, x + s - m - 1, y + m + 1), fill=col) 65 elif kind == 'restore': 66 d.rectangle((x + m + 2, y + m, x + s - m - 1, y + s - m - 3), outline=col) 67 d.rectangle((x + m, y + m + 3, x + s - m - 3, y + s - m - 1), outline=col, fill=FACE) 68 d.line((x + m, y + m + 4, x + s - m - 3, y + m + 4), fill=col) 69 elif kind == 'menu': 70 d.rectangle((x + m, y + s // 2 - 1, x + s - m - 1, y + s // 2 + 1), outline=col) 71 elif kind == 'shade': 72 d.line((x + m, y + m + 2, x + s - m - 1, y + m + 2), fill=col) 73 d.line((x + m, y + m + 3, x + s - m - 1, y + m + 3), fill=col) 74 elif kind == 'stick': 75 d.rectangle((x + s // 2 - 2, y + s // 2 - 2, x + s // 2 + 1, y + s // 2 + 1), fill=col) 76 77 # a piece of title bar, w wide 78 def title(w, active, h=TH): 79 im = Image.new('RGB', (w, h), TITLE[active]) 80 d = ImageDraw.Draw(im) 81 d.line((0, 0, w, 0), fill=BLACK) 82 d.line((0, 1, w, 1), fill=TITLE_HI[active]) 83 d.line((0, h - 1, w, h - 1), fill=BLACK) 84 return im 85 86 # a button sitting on its slot of title bar 87 def button(kind, state, active, w=TH, h=TH): 88 im = title(w, active, h) 89 d = ImageDraw.Draw(im) 90 x0 = (w - BS) // 2; y0 = (h - BS) // 2 91 face = {'prelight': (196, 196, 196), 'pressed': (150, 150, 150)}.get(state, FACE) 92 if not active and state == 'normal': 93 face = (150, 150, 150) 94 bevel(d, x0, y0, x0 + BS - 1, y0 + BS - 1, face, state == 'pressed') 95 o = 1 if state == 'pressed' else 0 96 glyph(d, kind, x0 + 1 + o, y0 + 1 + o, BS - 3, BLACK if active else (60, 60, 60)) 97 return im 98 99 # the bar along the bottom: gray, raised, cut by a line GRIP in from each end 100 def bottombar(w, active): 101 im = Image.new('RGB', (w, BB), FACE) 102 d = ImageDraw.Draw(im) 103 d.line((0, 0, w, 0), fill=BLACK) # the window's own edge 104 d.line((0, 1, w, 1), fill=WHITE) 105 d.line((0, BB - 1, w, BB - 1), fill=BLACK) 106 d.line((0, BB - 2, w, BB - 2), fill=DARK) 107 d.line((0, 0, 0, BB), fill=BLACK); d.line((w - 1, 0, w - 1, BB), fill=BLACK) 108 return im 109 110 def grip(active, right): 111 im = bottombar(GRIP, active) 112 d = ImageDraw.Draw(im) 113 x = 0 if right else GRIP - 1 114 d.line((x, 1, x, BB - 2), fill=BLACK) 115 d.line((x + (1 if right else -1), 2, x + (1 if right else -1), BB - 3), fill=WHITE if right else DARK) 116 return im 117 118 # ---------- xfce ---------- 119 120 XFWM_STATES = {'normal': 'active', 'prelight': 'prelight', 'pressed': 'pressed'} 121 122 def xfwm4(out): 123 d = os.path.join(out, 'themes', NAME, 'xfwm4') 124 for act in (True, False): 125 s = 'active' if act else 'inactive' 126 t = title(8, act) 127 ImageDraw.Draw(t).line((0, 0, 0, TH), fill=BLACK) 128 save(t, d, 'top-left-%s.png' % s) 129 t = title(8, act) 130 ImageDraw.Draw(t).line((7, 0, 7, TH), fill=BLACK) 131 save(t, d, 'top-right-%s.png' % s) 132 for i in range(1, 6): 133 save(title(32, act), d, 'title-%d-%s.png' % (i, s)) 134 save(Image.new('RGB', (B, 16), BLACK), d, 'left-%s.png' % s) 135 save(Image.new('RGB', (B, 16), BLACK), d, 'right-%s.png' % s) 136 save(grip(act, False), d, 'bottom-left-%s.png' % s) 137 save(grip(act, True), d, 'bottom-right-%s.png' % s) 138 save(bottombar(16, act).crop((1, 0, 15, BB)), d, 'bottom-%s.png' % s) 139 for k in ('hide', 'maximize', 'close', 'menu', 'shade', 'stick', 'maximize-toggled'): 140 kind = 'restore' if k == 'maximize-toggled' else k 141 for st, name in XFWM_STATES.items(): 142 if not act and st != 'normal': 143 continue 144 save(button(kind, st, act), d, '%s-%s.png' % (k, name if act else 'inactive')) 145 save_text('''button_offset=2 146 button_spacing=0 147 full_width_title=true 148 title_alignment=center 149 title_horizontal_offset=0 150 title_vertical_offset_active=0 151 title_vertical_offset_inactive=0 152 title_shadow_active=false 153 title_shadow_inactive=false 154 active_text_color=%s 155 inactive_text_color=%s 156 maximized_offset=0 157 shadow_delta_height=0 158 shadow_delta_width=0 159 shadow_delta_x=0 160 shadow_delta_y=0 161 shadow_opacity=0 162 ''' % (TEXT[True], TEXT[False]), d, 'themerc') 163 164 # ---------- mate and cinnamon: marco and muffin read the same metacity theme ---------- 165 166 def metacity(out): 167 d = os.path.join(out, 'themes', NAME, 'metacity-1') 168 # buttons as images, so they match xfce's exactly 169 for act in (True, False): 170 s = 'active' if act else 'inactive' 171 for kind in ('hide', 'maximize', 'restore', 'close', 'menu'): 172 for st in ('normal', 'prelight', 'pressed'): 173 save(button(kind, st, act), d, '%s-%s-%s.png' % (kind, st, s)) 174 def ops(kind): 175 xml = '' 176 for act in (True, False): 177 s = 'active' if act else 'inactive' 178 for st in ('normal', 'prelight', 'pressed'): 179 xml += '''<draw_ops name="%s_%s_%s"><image filename="%s-%s-%s.png" x="0" y="0" width="width" height="height"/></draw_ops> 180 ''' % (kind, st, s, kind, st, s) 181 return xml 182 frame_ops = '' 183 for act in (True, False): 184 s = 'active' if act else 'inactive' 185 frame_ops += '''<draw_ops name="frame_%(s)s"> 186 <rectangle color="#000000" x="0" y="0" width="width-1" height="height-1" filled="false"/> 187 </draw_ops> 188 <draw_ops name="title_%(s)s"> 189 <rectangle color="%(bg)s" x="0" y="0" width="width" height="height" filled="true"/> 190 <line color="%(hi)s" x1="0" y1="1" x2="width" y2="1"/> 191 <line color="#000000" x1="0" y1="height-1" x2="width" y2="height-1"/> 192 <title color="%(fg)s" x="(width - title_width) / 2 `max` 2" y="(height - title_height) / 2"/> 193 </draw_ops> 194 <draw_ops name="bottom_%(s)s"> 195 <rectangle color="%(face)s" x="0" y="height-%(bb)d" width="width" height="%(bb)d" filled="true"/> 196 <line color="#000000" x1="0" y1="height-%(bb)d" x2="width" y2="height-%(bb)d"/> 197 <line color="#ffffff" x1="1" y1="height-%(bb1)d" x2="width-2" y2="height-%(bb1)d"/> 198 <line color="%(dark)s" x1="1" y1="height-2" x2="width-2" y2="height-2"/> 199 <line color="#000000" x1="0" y1="height-1" x2="width" y2="height-1"/> 200 <line color="#000000" x1="%(g)d" y1="height-%(bb)d" x2="%(g)d" y2="height-1"/> 201 <line color="#ffffff" x1="%(g1)d" y1="height-%(bb1)d" x2="%(g1)d" y2="height-2"/> 202 <line color="#000000" x1="width-%(g1)d" y1="height-%(bb)d" x2="width-%(g1)d" y2="height-1"/> 203 <line color="%(dark)s" x1="width-%(g2)d" y1="height-%(bb1)d" x2="width-%(g2)d" y2="height-2"/> 204 <line color="#000000" x1="0" y1="0" x2="0" y2="height"/> 205 <line color="#000000" x1="width-1" y1="0" x2="width-1" y2="height"/> 206 </draw_ops> 207 ''' % dict(s=s, bg=hexc(TITLE[act]), hi=hexc(TITLE_HI[act]), fg=TEXT[act], face=hexc(FACE), 208 dark=hexc(DARK), bb=BB, bb1=BB - 1, g=GRIP, g1=GRIP + 1, g2=GRIP + 2) 209 buttons = '' 210 for act in (True, False): 211 s = 'active' if act else 'inactive' 212 buttons += '<frame_style name="normal_%s" geometry="normal">\n' % s 213 buttons += ' <piece position="entire_background" draw_ops="frame_%s"/>\n' % s 214 buttons += ' <piece position="titlebar" draw_ops="title_%s"/>\n' % s 215 buttons += ' <piece position="overlay" draw_ops="bottom_%s"/>\n' % s 216 for kind, mc in (('hide', 'minimize'), ('maximize', 'maximize'), ('close', 'close'), ('menu', 'menu')): 217 for st in ('normal', 'prelight', 'pressed'): 218 buttons += ' <button function="%s" state="%s" draw_ops="%s_%s_%s"/>\n' % (mc, st, kind, st, s) 219 for st in ('normal', 'prelight', 'pressed'): 220 for f in ('shade', 'unshade', 'above', 'unabove', 'stick', 'unstick'): 221 buttons += ' <button function="%s" state="%s"><draw_ops></draw_ops></button>\n' % (f, st) 222 for f in ('left_left_background', 'left_middle_background', 'left_right_background', 223 'right_left_background', 'right_middle_background', 'right_right_background'): 224 buttons += ' <button function="%s" state="%s"><draw_ops></draw_ops></button>\n' % (f, st) 225 buttons += '</frame_style>\n' 226 buttons += '<frame_style name="max_%s" geometry="max" parent="normal_%s">\n' % (s, s) 227 for st in ('normal', 'prelight', 'pressed'): 228 buttons += ' <button function="maximize" state="%s" draw_ops="restore_%s_%s"/>\n' % (st, st, s) 229 buttons += ' <piece position="overlay"><draw_ops></draw_ops></piece>\n' 230 buttons += '</frame_style>\n' 231 xml = '''<?xml version="1.0"?> 232 <metacity_theme> 233 <info> 234 <name>%(name)s</name> 235 <author>Chamesle Linux</author> 236 <copyright>GPL-3.0-or-later</copyright> 237 <date>2026</date> 238 <description>Black title bars, gray raised buttons, a resize bar along the bottom</description> 239 </info> 240 <frame_geometry name="normal" title_scale="medium" rounded_top_left="false" rounded_top_right="false"> 241 <distance name="left_width" value="%(b)d"/> 242 <distance name="right_width" value="%(b)d"/> 243 <distance name="bottom_height" value="%(bb)d"/> 244 <distance name="left_titlebar_edge" value="2"/> 245 <distance name="right_titlebar_edge" value="2"/> 246 <distance name="title_vertical_pad" value="4"/> 247 <aspect_ratio name="button" value="1.0"/> 248 <border name="title_border" left="2" right="2" top="2" bottom="2"/> 249 <border name="button_border" left="0" right="0" top="0" bottom="0"/> 250 </frame_geometry> 251 <frame_geometry name="max" parent="normal" has_title="true"> 252 <distance name="left_width" value="0"/> 253 <distance name="right_width" value="0"/> 254 <distance name="bottom_height" value="0"/> 255 </frame_geometry> 256 <frame_geometry name="small" parent="normal"> 257 <distance name="bottom_height" value="%(b)d"/> 258 </frame_geometry> 259 <frame_geometry name="border" parent="normal" has_title="false"> 260 <distance name="bottom_height" value="%(b)d"/> 261 <distance name="title_vertical_pad" value="0"/> 262 <border name="title_border" left="0" right="0" top="0" bottom="0"/> 263 </frame_geometry> 264 %(ops)s 265 %(frame_ops)s 266 %(buttons)s 267 <frame_style name="border" geometry="border" parent="normal_active"> 268 <piece position="titlebar"><draw_ops></draw_ops></piece> 269 <piece position="overlay"><draw_ops></draw_ops></piece> 270 </frame_style> 271 <frame_style_set name="normal"> 272 <frame focus="yes" state="normal" resize="both" style="normal_active"/> 273 <frame focus="no" state="normal" resize="both" style="normal_inactive"/> 274 <frame focus="yes" state="maximized" style="max_active"/> 275 <frame focus="no" state="maximized" style="max_inactive"/> 276 <frame focus="yes" state="shaded" style="normal_active"/> 277 <frame focus="no" state="shaded" style="normal_inactive"/> 278 <frame focus="yes" state="maximized_and_shaded" style="max_active"/> 279 <frame focus="no" state="maximized_and_shaded" style="max_inactive"/> 280 </frame_style_set> 281 <frame_style_set name="border"> 282 <frame focus="yes" state="normal" resize="both" style="border"/> 283 <frame focus="no" state="normal" resize="both" style="border"/> 284 <frame focus="yes" state="maximized" style="border"/> 285 <frame focus="no" state="maximized" style="border"/> 286 <frame focus="yes" state="shaded" style="border"/> 287 <frame focus="no" state="shaded" style="border"/> 288 <frame focus="yes" state="maximized_and_shaded" style="border"/> 289 <frame focus="no" state="maximized_and_shaded" style="border"/> 290 </frame_style_set> 291 <window type="normal" style_set="normal"/> 292 <window type="dialog" style_set="normal"/> 293 <window type="modal_dialog" style_set="normal"/> 294 <window type="menu" style_set="normal"/> 295 <window type="utility" style_set="normal"/> 296 <window type="border" style_set="border"/> 297 </metacity_theme> 298 ''' % dict(name=NAME, b=B, bb=BB, ops=''.join(ops(k) for k in ('hide', 'maximize', 'restore', 'close', 'menu')), 299 frame_ops=frame_ops, buttons=buttons) 300 for v in (2, 3): 301 save_text(xml, d, 'metacity-theme-%d.xml' % v) 302 303 # ---------- cinnamon's own panel and menus ---------- 304 305 CINNAMON = '''@import url("file:///usr/share/cinnamon/theme/cinnamon.css"); 306 /* chamesle gray for the cinnamon panel and menus: gray, raised, square */ 307 #panel, .panel-bottom, .panel-top, .panel-left, .panel-right { 308 background-color: #aeaeae; 309 background-gradient-direction: none; 310 border-top: 1px solid #ffffff; 311 box-shadow: none; 312 color: #000000; 313 font-weight: normal; 314 } 315 .panel-bottom { border-top: 1px solid #ffffff; } 316 #panel StLabel, .panel-bottom StLabel, .applet-label { color: #000000; text-shadow: none; } 317 .applet-box { color: #000000; } 318 .applet-box:hover, .applet-box:checked { background-color: #c4c4c4; } 319 .window-list-item-box, .grouped-window-list-item-box { 320 border-radius: 0; 321 background-color: #aeaeae; 322 border-top: 1px solid #ffffff; border-left: 1px solid #ffffff; 323 border-bottom: 1px solid #000000; border-right: 1px solid #000000; 324 color: #000000; 325 margin: 2px 1px; 326 } 327 .window-list-item-box:hover, .grouped-window-list-item-box:hover { background-color: #c4c4c4; } 328 .window-list-item-box:focus, .window-list-item-box:active, .window-list-item-box:checked, 329 .grouped-window-list-item-box:focus, .grouped-window-list-item-box:active, .grouped-window-list-item-box:checked { 330 background-color: #969696; 331 background-gradient-direction: none; 332 border-top: 1px solid #000000; border-left: 1px solid #000000; 333 border-bottom: 1px solid #ffffff; border-right: 1px solid #ffffff; 334 } 335 .window-list-item-box StLabel, .grouped-window-list-item-box StLabel { color: #000000; } 336 .menu, .popup-menu-boxpointer, .applet-box .popup-menu, .popup-menu { 337 -arrow-background-color: #aeaeae; 338 -arrow-border-color: #000000; 339 -arrow-border-width: 1px; 340 -arrow-border-radius: 0; 341 -arrow-base: 0; 342 -arrow-rise: 0; 343 color: #000000; 344 } 345 .popup-menu-content, .menu-context-menu { background-color: #aeaeae; border: 1px solid #000000; border-radius: 0; box-shadow: none; } 346 .popup-menu-item { color: #000000; } 347 .popup-menu-item:active, .popup-menu-item:hover { background-color: #000000; color: #ffffff; border-radius: 0; } 348 .popup-menu-item:active StLabel, .popup-menu-item:hover StLabel { color: #ffffff; } 349 .popup-separator-menu-item { -gradient-start: #555555; -gradient-end: #555555; -margin-horizontal: 4px; height: 1px; } 350 .menu-applications-outer-box, .menu-favorites-box, .menu-places-box, .menu-categories-box { color: #000000; } 351 .menu-favorites-box { background-color: #9a9a9a; border: 1px solid #555555; border-radius: 0; } 352 .menu-application-button, .menu-category-button { color: #000000; border-radius: 0; } 353 .menu-application-button-selected, .menu-category-button-selected, .menu-application-button:hover { 354 background-color: #000000; color: #ffffff; border-radius: 0; 355 } 356 .menu-application-button-selected StLabel, .menu-category-button-selected StLabel { color: #ffffff; } 357 #menu-search-entry, .menu-search-entry { 358 background-color: #ffffff; color: #000000; border-radius: 0; 359 border-top: 1px solid #555555; border-left: 1px solid #555555; 360 border-bottom: 1px solid #ffffff; border-right: 1px solid #ffffff; 361 box-shadow: none; 362 } 363 .calendar, .calendar-main-box { color: #000000; } 364 .notification, .notification-button { background-color: #aeaeae; color: #000000; border: 1px solid #000000; border-radius: 0; } 365 .switcher-list, .info-osd, .osd-window { 366 background-color: #aeaeae; color: #000000; border: 1px solid #000000; border-radius: 0; box-shadow: none; 367 } 368 .switcher-list .item-box:selected, .switcher-list .item-box:outlined { background-color: #000000; color: #ffffff; border-radius: 0; } 369 .tooltip, StTooltip { background-color: #ffffe1; color: #000000; border: 1px solid #000000; border-radius: 0; } 370 ''' 371 372 def cinnamon(out): 373 save_text(CINNAMON, out, 'themes', NAME, 'cinnamon', 'cinnamon.css') 374 375 # ---------- kde: frames as nine-piece svgs, all square and opaque ---------- 376 377 def h6(c): 378 return '#%02x%02x%02x' % c 379 380 def rect(x, y, w, h, col): 381 return '<rect x="%g" y="%g" width="%g" height="%g" fill="%s"/>' % (x, y, w, h, h6(col)) 382 383 # nine pieces of a w x h frame. top/bottom are lists of row colours from the outside in, 384 # left/right of column colours from the outside in. a corner pixel takes the colour of whichever 385 # edge line it's on further out 386 def nine(prefix, w, h, top, bottom, left, right, center): 387 p = prefix + '-' if prefix else '' 388 t, b, l, r = len(top), len(bottom), len(left), len(right) 389 g = {} 390 g['top'] = ''.join(rect(l, i, w - l - r, 1, top[i]) for i in range(t)) 391 g['bottom'] = ''.join(rect(l, h - 1 - i, w - l - r, 1, bottom[i]) for i in range(b)) 392 g['left'] = ''.join(rect(i, t, 1, h - t - b, left[i]) for i in range(l)) 393 g['right'] = ''.join(rect(w - 1 - i, t, 1, h - t - b, right[i]) for i in range(r)) 394 g['center'] = rect(l, t, w - l - r, h - t - b, center) 395 def corner(rows, cols, x0, y0, flipx, flipy): 396 o = '' 397 for yy in range(len(rows)): 398 for xx in range(len(cols)): 399 col = cols[xx] if xx < yy or (xx == 0) else rows[yy] 400 if yy == 0 and xx > 0: 401 col = rows[0] 402 X = x0 + (len(cols) - 1 - xx if flipx else xx) 403 Y = y0 + (len(rows) - 1 - yy if flipy else yy) 404 o += rect(X, Y, 1, 1, col) 405 return o 406 g['topleft'] = corner(top, left, 0, 0, False, False) 407 g['topright'] = corner(top, right, w - r, 0, True, False) 408 g['bottomleft'] = corner(bottom, left, 0, h - b, False, True) 409 g['bottomright'] = corner(bottom, right, w - r, h - b, True, True) 410 return ['<g id="%s%s">%s</g>' % (p, k, v) for k, v in g.items()] 411 412 def svgdoc(w, h, els): 413 return '<?xml version="1.0"?>\n<svg xmlns="http://www.w3.org/2000/svg" width="%d" height="%d">%s</svg>\n' % (w, h, ''.join(els)) 414 415 def title_rows(act): 416 return [BLACK, TITLE_HI[act]] + [TITLE[act]] * (TH - 3) + [BLACK] 417 418 BAR = [BLACK, DARK] + [FACE] * (BB - 3) + [WHITE] # bottom bar, from the outside in (the window's edge last) 419 420 def aurorae(out): 421 d = os.path.join(out, 'aurorae', 'themes', 'ChamesleGray') 422 W = H = 120 423 els = [] 424 for pre, act in (('decoration', True), ('decoration-inactive', False)): 425 els += nine(pre, W, H, title_rows(act), BAR[:-1] + [BLACK], [BLACK], [BLACK], FACE) 426 for pre, act in (('decoration-maximized', True), ('decoration-maximized-inactive', False)): 427 els += nine(pre, W, H, title_rows(act)[1:], [], [], [], FACE) 428 save_text(svgdoc(W, H, els), d, 'decoration.svg') 429 S = TH - 4 430 def bsvg(kind): 431 out_ = [] 432 for st, pst, act in (('active', 'normal', True), ('hover', 'prelight', True), ('pressed', 'pressed', True), 433 ('inactive', 'normal', False), ('deactivated', 'normal', False)): 434 im = button(kind, pst, act, S, S) 435 # kwin skips bitmaps inside svgs, so each pixel of the button becomes a rect, rows merged 436 px = im.load(); rs = '' 437 for y in range(S): 438 x = 0 439 while x < S: 440 c0 = px[x, y]; x1 = x 441 while x1 + 1 < S and px[x1 + 1, y] == c0: 442 x1 += 1 443 rs += rect(x, y, x1 - x + 1, 1, c0) 444 x = x1 + 1 445 out_.append('<g id="%s-center">%s</g>' % (st, rs)) 446 return svgdoc(S, S, out_) 447 for kind, fn in (('close', 'close'), ('maximize', 'maximize'), ('restore', 'restore'), ('hide', 'minimize')): 448 save_text(bsvg(kind), d, fn + '.svg') 449 save_text('''[General] 450 ActiveTextColor=255,255,255 451 InactiveTextColor=200,200,200 452 UseTextShadow=false 453 HaloActive=false 454 HaloInactive=false 455 TitleAlignment=Center 456 TitleVerticalAlignment=Center 457 Animation=0 458 Shadow=false 459 460 [Layout] 461 BorderLeft=%d 462 BorderRight=%d 463 BorderBottom=%d 464 BorderTop=0 465 TitleEdgeTop=2 466 TitleEdgeBottom=2 467 TitleEdgeLeft=3 468 TitleEdgeRight=3 469 TitleEdgeTopMaximized=1 470 TitleEdgeBottomMaximized=1 471 TitleEdgeLeftMaximized=2 472 TitleEdgeRightMaximized=2 473 TitleBorderLeft=6 474 TitleBorderRight=6 475 TitleHeight=%d 476 ButtonWidth=%d 477 ButtonWidthMinimize=%d 478 ButtonWidthMaximizeRestore=%d 479 ButtonWidthClose=%d 480 ButtonHeight=%d 481 ButtonSpacing=2 482 ButtonMarginTop=0 483 ButtonMarginTopMaximized=0 484 ExplicitButtonSpacer=8 485 PaddingTop=0 486 PaddingBottom=0 487 PaddingLeft=0 488 PaddingRight=0 489 ''' % (B, B, BB, S, S, S, S, S, S), d, 'ChamesleGrayrc') 490 save_text('''[Desktop Entry] 491 Name=Chamesle Gray 492 Comment=Black title bars, gray raised buttons, a resize bar along the bottom 493 X-KDE-PluginInfo-Author=Chamesle 494 X-KDE-PluginInfo-Name=ChamesleGray 495 X-KDE-PluginInfo-Version=0.8 496 X-KDE-PluginInfo-License=GPL-3.0-or-later 497 ''', d, 'metadata.desktop') 498 499 PLASMA_COLORS = '''[Colors:Window] 500 BackgroundNormal=174,174,174 501 ForegroundNormal=0,0,0 502 ForegroundInactive=60,60,60 503 DecorationFocus=0,0,0 504 DecorationHover=255,255,255 505 506 [Colors:View] 507 BackgroundNormal=174,174,174 508 ForegroundNormal=0,0,0 509 ForegroundInactive=60,60,60 510 DecorationFocus=0,0,0 511 DecorationHover=255,255,255 512 513 [Colors:Button] 514 BackgroundNormal=174,174,174 515 ForegroundNormal=0,0,0 516 DecorationFocus=0,0,0 517 DecorationHover=255,255,255 518 519 [Colors:Selection] 520 BackgroundNormal=255,255,255 521 ForegroundNormal=0,0,0 522 523 [Colors:Tooltip] 524 BackgroundNormal=255,255,225 525 ForegroundNormal=0,0,0 526 527 [Colors:Complementary] 528 BackgroundNormal=174,174,174 529 ForegroundNormal=0,0,0 530 531 [Colors:Header] 532 BackgroundNormal=174,174,174 533 ForegroundNormal=0,0,0 534 ''' 535 536 def plasma(out): 537 d = os.path.join(out, 'plasma', 'desktoptheme', 'chamesle-gray') 538 raised = ([WHITE], [BLACK, DARK], [WHITE], [BLACK, DARK]) 539 sunk = ([BLACK, DARK], [WHITE], [BLACK, DARK], [WHITE]) 540 # the panel: gray, a white line where it meets the desktop 541 els = [] 542 for side, (t, b, l, r) in (('', ([WHITE], [DARK], [WHITE], [DARK])), ('south', ([BLACK, WHITE], [FACE], [FACE], [FACE])), 543 ('north', ([FACE], [DARK, BLACK][::-1], [FACE], [FACE])), ('west', ([FACE], [FACE], [FACE], [BLACK, DARK])), 544 ('east', ([FACE], [FACE], [BLACK, WHITE], [FACE]))): 545 els += nine(side, 64, 32, t, b, l, r, FACE) 546 save_text(svgdoc(64, 32, els), d, 'widgets/panel-background.svg') 547 # menus and popups: gray with a black line round them 548 els = nine('', 64, 64, [BLACK, WHITE], [BLACK, DARK], [BLACK, WHITE], [BLACK, DARK], FACE) 549 save_text(svgdoc(64, 64, els), d, 'dialogs/background.svg') 550 save_text(svgdoc(64, 64, nine('', 64, 64, [BLACK], [BLACK], [BLACK], [BLACK], (255, 255, 225))), d, 'widgets/tooltip.svg') 551 save_text(svgdoc(64, 64, nine('', 64, 64, *raised, FACE)), d, 'widgets/background.svg') 552 # the taskbar: each window a raised button, the one you're in pressed in 553 els = [] 554 for pre, fr, col in (('normal', raised, FACE), ('hover', raised, (196, 196, 196)), ('focus', sunk, (150, 150, 150)), 555 ('attention', raised, (220, 200, 120)), ('minimized', raised, (160, 160, 160))): 556 els += nine(pre, 48, 48, *fr, col) 557 save_text(svgdoc(48, 48, els), d, 'widgets/tasks.svg') 558 save_text('''{ 559 "KPlugin": { 560 "Authors": [{"Name": "Chamesle"}], 561 "Description": "Gray panels and menus, raised one pixel", 562 "Id": "chamesle-gray", 563 "License": "GPL-3.0-or-later", 564 "Name": "Chamesle Gray", 565 "Version": "0.8" 566 }, 567 "X-Plasma-API": "5.0" 568 } 569 ''', d, 'metadata.json') 570 save_text(PLASMA_COLORS, d, 'colors') 571 572 def colors(out): 573 save_text('''[General] 574 ColorScheme=ChamesleGray 575 Name=Chamesle Gray 576 577 [ColorEffects:Disabled] 578 Color=110,110,110 579 ColorAmount=0 580 ColorEffect=0 581 ContrastAmount=0.5 582 ContrastEffect=1 583 IntensityAmount=0 584 IntensityEffect=0 585 586 [ColorEffects:Inactive] 587 ChangeSelectionColor=false 588 Enable=false 589 590 [Colors:Button] 591 BackgroundAlternate=160,160,160 592 BackgroundNormal=174,174,174 593 DecorationFocus=0,0,0 594 DecorationHover=255,255,255 595 ForegroundActive=0,0,0 596 ForegroundInactive=70,70,70 597 ForegroundLink=0,0,170 598 ForegroundNegative=170,0,0 599 ForegroundNeutral=130,90,0 600 ForegroundNormal=0,0,0 601 ForegroundPositive=0,110,0 602 ForegroundVisited=85,26,139 603 604 [Colors:Selection] 605 BackgroundAlternate=240,240,240 606 BackgroundNormal=255,255,255 607 DecorationFocus=0,0,0 608 DecorationHover=85,85,85 609 ForegroundActive=0,0,0 610 ForegroundInactive=70,70,70 611 ForegroundLink=0,0,170 612 ForegroundNegative=170,0,0 613 ForegroundNeutral=130,90,0 614 ForegroundNormal=0,0,0 615 ForegroundPositive=0,110,0 616 ForegroundVisited=85,26,139 617 618 [Colors:Tooltip] 619 BackgroundAlternate=255,255,225 620 BackgroundNormal=255,255,225 621 DecorationFocus=0,0,0 622 DecorationHover=0,0,0 623 ForegroundNormal=0,0,0 624 ForegroundInactive=70,70,70 625 626 [Colors:View] 627 BackgroundAlternate=240,240,240 628 BackgroundNormal=255,255,255 629 DecorationFocus=0,0,0 630 DecorationHover=85,85,85 631 ForegroundActive=0,0,0 632 ForegroundInactive=70,70,70 633 ForegroundLink=0,0,170 634 ForegroundNegative=170,0,0 635 ForegroundNeutral=130,90,0 636 ForegroundNormal=0,0,0 637 ForegroundPositive=0,110,0 638 ForegroundVisited=85,26,139 639 640 [Colors:Window] 641 BackgroundAlternate=160,160,160 642 BackgroundNormal=174,174,174 643 DecorationFocus=0,0,0 644 DecorationHover=255,255,255 645 ForegroundActive=0,0,0 646 ForegroundInactive=70,70,70 647 ForegroundLink=0,0,170 648 ForegroundNegative=170,0,0 649 ForegroundNeutral=130,90,0 650 ForegroundNormal=0,0,0 651 ForegroundPositive=0,110,0 652 ForegroundVisited=85,26,139 653 654 [Colors:Complementary] 655 BackgroundNormal=174,174,174 656 ForegroundNormal=0,0,0 657 DecorationFocus=0,0,0 658 DecorationHover=255,255,255 659 660 [Colors:Header] 661 BackgroundNormal=174,174,174 662 ForegroundNormal=0,0,0 663 DecorationFocus=0,0,0 664 DecorationHover=255,255,255 665 666 [WM] 667 activeBackground=0,0,0 668 activeForeground=255,255,255 669 inactiveBackground=76,76,76 670 inactiveForeground=200,200,200 671 ''', out, 'color-schemes', 'ChamesleGray.colors') 672 673 # ---------- gtk: onestepback, with our title bar ---------- 674 # cinnamon's muffin draws window frames from the gtk theme, not from metacity-1, 675 # and so do apps that draw their own title bar. everything else is onestepback's 676 677 GTK = """@import url("file:///usr/share/themes/OneStepBack/gtk-3.0/gtk.css"); 678 /* chamesle gray: the title bar, the rest is onestepback */ 679 decoration, window.ssd decoration, .titlebar.default-decoration, window { border-radius: 0; } 680 window.ssd decoration, window.csd decoration { box-shadow: 0 0 0 1px #000000; margin: 4px; } 681 window.ssd decoration:backdrop, window.csd decoration:backdrop { box-shadow: 0 0 0 1px #000000; } 682 .titlebar.default-decoration, window.ssd .titlebar, window.ssd headerbar { 683 background-color: %(on)s; 684 background-image: none; 685 color: #ffffff; 686 border: none; 687 border-radius: 0; 688 box-shadow: inset 0 1px %(on_hi)s; 689 min-height: 20px; 690 padding: 0 2px; 691 } 692 .titlebar.default-decoration:backdrop, window.ssd .titlebar:backdrop, window.ssd headerbar:backdrop { 693 background-color: %(off)s; 694 box-shadow: inset 0 1px %(off_hi)s; 695 color: #c8c8c8; 696 } 697 .titlebar.default-decoration .title, window.ssd .titlebar .title { color: #ffffff; font-weight: bold; } 698 .titlebar.default-decoration .title:backdrop, window.ssd .titlebar .title:backdrop { color: #c8c8c8; } 699 .titlebar.default-decoration button.titlebutton, window.ssd .titlebar button.titlebutton { 700 min-width: 14px; 701 min-height: 14px; 702 padding: 0; 703 margin: 2px 1px; 704 border-radius: 0; 705 border-style: solid; 706 border-width: 1px; 707 border-color: #ffffff #000000 #000000 #ffffff; 708 background-color: %(face)s; 709 background-image: none; 710 box-shadow: inset -1px -1px %(dark)s; 711 color: #000000; 712 -gtk-icon-shadow: none; 713 } 714 .titlebar.default-decoration button.titlebutton:hover, window.ssd .titlebar button.titlebutton:hover { background-color: #c4c4c4; } 715 .titlebar.default-decoration button.titlebutton:active, window.ssd .titlebar button.titlebutton:active { 716 background-color: #969696; 717 border-color: #000000 #ffffff #ffffff #000000; 718 box-shadow: inset 1px 1px %(dark)s; 719 } 720 .titlebar.default-decoration button.titlebutton:backdrop, window.ssd .titlebar button.titlebutton:backdrop { 721 background-color: #969696; 722 color: #3c3c3c; 723 } 724 """ 725 726 def gtk(out): 727 d = os.path.join(out, 'themes', NAME) 728 save_text(GTK % dict(on=hexc(TITLE[True]), on_hi=hexc(TITLE_HI[True]), off=hexc(TITLE[False]), 729 off_hi=hexc(TITLE_HI[False]), face=hexc(FACE), dark=hexc(DARK)), d, 'gtk-3.0', 'gtk.css') 730 # gtk 2 and 4 apps get onestepback as it is 731 for v in ('gtk-2.0', 'gtk-4.0'): 732 l = os.path.join(d, v) 733 if not os.path.lexists(l): 734 os.symlink('../OneStepBack/' + v, l) 735 736 def index(out): 737 save_text('''[Desktop Entry] 738 Type=X-GNOME-Metatheme 739 Name=%s 740 Comment=Black title bars and gray raised buttons, like the workstations of 2001 741 Encoding=UTF-8 742 743 [X-GNOME-Metatheme] 744 GtkTheme=%s 745 MetacityTheme=%s 746 IconTheme=Chamesle-Glass 747 ''' % (NAME, NAME, NAME), out, 'themes', NAME, 'index.theme') 748 749 if __name__ == '__main__': 750 out = sys.argv[1] 751 index(out); gtk(out); xfwm4(out); metacity(out); cinnamon(out); aurorae(out); plasma(out); colors(out)