118 lines
3.6 KiB
Bash
Executable File
118 lines
3.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# 9001-wallpaper.hook.chroot — generate /usr/share/bee/wallpaper.png inside chroot
|
|
set -e
|
|
echo "=== generating bee wallpaper ==="
|
|
mkdir -p /usr/share/bee
|
|
|
|
python3 - <<'PYEOF'
|
|
from PIL import Image, ImageDraw, ImageFont, ImageFilter
|
|
import os
|
|
|
|
W, H = 1920, 1080
|
|
|
|
GLYPHS = {
|
|
'E': ["11111", "10000", "11110", "10000", "10000", "10000", "11111"],
|
|
'A': ["01110", "10001", "10001", "11111", "10001", "10001", "10001"],
|
|
'S': ["01111", "10000", "10000", "01110", "00001", "00001", "11110"],
|
|
'Y': ["10001", "10001", "01010", "00100", "00100", "00100", "00100"],
|
|
'B': ["11110", "10001", "10001", "11110", "10001", "10001", "11110"],
|
|
'-': ["00000", "00000", "11111", "00000", "00000", "00000", "00000"],
|
|
}
|
|
|
|
TITLE = "EASY-BEE"
|
|
SUBTITLE = "Hardware Audit LiveCD"
|
|
CELL = 30
|
|
GLYPH_GAP = 18
|
|
ROW_GAP = 6
|
|
|
|
FG = (0xF6, 0xD0, 0x47)
|
|
FG_DIM = (0xD4, 0xA9, 0x1C)
|
|
SHADOW = (0x5E, 0x47, 0x05)
|
|
SUB = (0x96, 0x7A, 0x17)
|
|
BG = (0x05, 0x05, 0x05)
|
|
|
|
SUB_FONT_CANDIDATES = [
|
|
'/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf',
|
|
'/usr/share/fonts/truetype/liberation2/LiberationSans-Bold.ttf',
|
|
'/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf',
|
|
'/usr/share/fonts/truetype/freefont/FreeSansBold.ttf',
|
|
]
|
|
|
|
|
|
def load_font(size):
|
|
for path in SUB_FONT_CANDIDATES:
|
|
if os.path.exists(path):
|
|
return ImageFont.truetype(path, size)
|
|
return ImageFont.load_default()
|
|
|
|
|
|
def glyph_width(ch):
|
|
return len(GLYPHS[ch][0])
|
|
|
|
|
|
def render_logo_mask():
|
|
width_cells = 0
|
|
for idx, ch in enumerate(TITLE):
|
|
width_cells += glyph_width(ch)
|
|
if idx != len(TITLE) - 1:
|
|
width_cells += 1
|
|
mask_w = width_cells * CELL + (len(TITLE) - 1) * GLYPH_GAP
|
|
mask_h = 7 * CELL + 6 * ROW_GAP
|
|
mask = Image.new('L', (mask_w, mask_h), 0)
|
|
draw = ImageDraw.Draw(mask)
|
|
|
|
cx = 0
|
|
for idx, ch in enumerate(TITLE):
|
|
glyph = GLYPHS[ch]
|
|
for row_idx, row in enumerate(glyph):
|
|
for col_idx, cell in enumerate(row):
|
|
if cell != '1':
|
|
continue
|
|
x0 = cx + col_idx * CELL
|
|
y0 = row_idx * (CELL + ROW_GAP)
|
|
x1 = x0 + CELL - 4
|
|
y1 = y0 + CELL - 4
|
|
draw.rounded_rectangle((x0, y0, x1, y1), radius=4, fill=255)
|
|
cx += glyph_width(ch) * CELL
|
|
if idx != len(TITLE) - 1:
|
|
cx += CELL + GLYPH_GAP
|
|
return mask
|
|
|
|
|
|
img = Image.new('RGB', (W, H), BG)
|
|
draw = ImageDraw.Draw(img)
|
|
|
|
# Soft amber glow under the logo without depending on font rendering.
|
|
glow = Image.new('RGBA', (W, H), (0, 0, 0, 0))
|
|
glow_draw = ImageDraw.Draw(glow)
|
|
glow_draw.ellipse((360, 250, 1560, 840), fill=(180, 120, 10, 56))
|
|
glow_draw.ellipse((520, 340, 1400, 760), fill=(255, 190, 40, 36))
|
|
glow = glow.filter(ImageFilter.GaussianBlur(60))
|
|
img = Image.alpha_composite(img.convert('RGBA'), glow)
|
|
|
|
logo_mask = render_logo_mask()
|
|
logo_w, logo_h = logo_mask.size
|
|
logo_x = (W - logo_w) // 2
|
|
logo_y = 290
|
|
|
|
shadow_mask = logo_mask.filter(ImageFilter.GaussianBlur(2))
|
|
img.paste(SHADOW, (logo_x + 16, logo_y + 14), shadow_mask)
|
|
img.paste(FG_DIM, (logo_x + 8, logo_y + 7), logo_mask)
|
|
img.paste(FG, (logo_x, logo_y), logo_mask)
|
|
|
|
font_sub = load_font(30)
|
|
sub_bb = draw.textbbox((0, 0), SUBTITLE, font=font_sub)
|
|
sub_x = (W - (sub_bb[2] - sub_bb[0])) // 2
|
|
sub_y = logo_y + logo_h + 54
|
|
draw = ImageDraw.Draw(img)
|
|
draw.text((sub_x + 2, sub_y + 2), SUBTITLE, font=font_sub, fill=(35, 28, 6))
|
|
draw.text((sub_x, sub_y), SUBTITLE, font=font_sub, fill=SUB)
|
|
|
|
img = img.convert('RGB')
|
|
|
|
img.save('/usr/share/bee/wallpaper.png', optimize=True)
|
|
print('wallpaper written: /usr/share/bee/wallpaper.png')
|
|
PYEOF
|
|
|
|
echo "=== wallpaper done ==="
|