#!/bin/bash
# https://ocv.me/dev/?wark.sh

m='WARK'
w=$(tput cols || echo 80)
h=$(tput lines || echo 24)
l=${#m}
w=$((w-l))
pad="$(head -c $((l+4)) /dev/zero | tr '\0' ' ')"

while true
do
	bri=$(( (RANDOM%2) ))
	fg=$(( (RANDOM%7) ))
	bg=$(( (RANDOM%7) ))
	md=$(( (RANDOM%7) ))
	x=$(( (RANDOM%(w-4)) +2 ))
	y=$(( (RANDOM%(h-2)) +2 ))

	printf '\033[%d;3%d;4%d;%dm' $bri $fg $bg $md
	printf '\033[%d;%dH%s\033[%d;%dH%s' $((y-1)) $x "$pad" $((y+1)) $x "$pad"
	printf '\033[%d;%dH  %s  \033[0m' $y $x "$m"
	
	read -u1 -r -t 0.01
done

# /etc/inittab
# tty1::respawn:/wark.sh
