#!/usr/bin/env python3
"""
GRUB Background Generator
Einfaches Hintergrundbild für GRUB Bootloader
"""

from PIL import Image, ImageDraw, ImageFont
import os

# Farben
BG_BLACK = (12, 12, 15)
TEXT_WHITE = (230, 230, 230)
TEXT_GRAY = (120, 120, 120)
ACCENT_CYAN = (100, 200, 255)

# Bildgröße (GRUB Standard)
WIDTH = 1920
HEIGHT = 1080

# Erstelle Bild
img = Image.new('RGB', (WIDTH, HEIGHT), BG_BLACK)
draw = ImageDraw.Draw(img)

# Versuche Font zu laden
try:
    font_paths = [
        '/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf',
        '/usr/share/fonts/truetype/liberation/LiberationMono-Bold.ttf',
    ]

    font_large = None
    font_small = None

    for font_path in font_paths:
        if os.path.exists(font_path):
            font_large = ImageFont.truetype(font_path, 72)
            font_small = ImageFont.truetype(font_path, 36)
            break

    if not font_large:
        raise Exception("No font found")

except:
    print("Font nicht gefunden, nutze Default")
    font_large = ImageFont.load_default()
    font_small = ImageFont.load_default()

# Zentrierter Text
main_text = "RDP THIN CLIENT"
bbox = draw.textbbox((0, 0), main_text, font=font_large)
text_width = bbox[2] - bbox[0]
text_x = (WIDTH - text_width) // 2
text_y = (HEIGHT // 2) - 100

draw.text((text_x, text_y), main_text, font=font_large, fill=TEXT_WHITE)

# Subtext
sub_text = "HackerSoft · Hacker-Net Telekommunikation"
bbox = draw.textbbox((0, 0), sub_text, font=font_small)
text_width = bbox[2] - bbox[0]
sub_x = (WIDTH - text_width) // 2
sub_y = text_y + 120

draw.text((sub_x, sub_y), sub_text, font=font_small, fill=ACCENT_CYAN)

# Speichern
output_path = os.path.join(os.path.dirname(__file__), 'grub-background.png')
img.save(output_path, 'PNG')
print(f"GRUB Background erstellt: {output_path}")
print(f"Größe: {WIDTH}x{HEIGHT}")
