From ffdff15528773320cc6487c763b4526b84dc115c Mon Sep 17 00:00:00 2001 From: Candifloss Date: Mon, 29 Jun 2026 10:53:13 +0000 Subject: [PATCH] Add ANSI/motd.py --- ANSI/motd.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 ANSI/motd.py diff --git a/ANSI/motd.py b/ANSI/motd.py new file mode 100644 index 0000000..8f7675b --- /dev/null +++ b/ANSI/motd.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 + +# Generate a colorful "Message Of The Day" using ANSII colors +# /etc/motd +# Get ASCII art at https://patorjk.com/software/taag/#p=display&f=Pagga or somewhere else + +from pathlib import Path +from random import randint + +# Config +DESCRIPTION = "This Is A Debian Server" + +BG = (36, 36, 36) +DESC = (18, 117, 130) + +ASCII_ART = r""" +░█▀▄░█▀▀░█▀▄░▀█▀░█▀█░█▀█ +░█░█░█▀▀░█▀▄░░█░░█▀█░█░█ +░▀▀░░▀▀▀░▀▀░░▀▀▀░▀░▀░▀░▀ +""".strip() + + +def fg(r: int, g: int, b: int) -> str: + return f"\033[38;2;{r};{g};{b}m" + + +def bg(r: int, g: int, b: int) -> str: + return f"\033[48;2;{r};{g};{b}m" + + +RESET = "\033[0m" + +# Get random RGB colors in the specified range +ART_FG = fg( + randint(10, 45), # R + randint(55, 95), # G + randint(55, 95), # B +) + +ART_BG = bg(*BG) +DESC_FG = fg(*DESC) + +motd = "\n".join( + [ + *( + f"{ART_FG}{ART_BG} {line} {RESET}" + for line in ASCII_ART.splitlines() + ), + f"{DESC_FG}{DESCRIPTION}{RESET}", + "", + ] +) + +Path("/etc/motd").write_text(motd) \ No newline at end of file