#! /bin/bash
trap ctrlC INT
ctrlC () {
#reset colour and cursor
printf "\x1b[0m\x1b[?25h"
exit
}
gotoxy () {
local -i X=$1
local -i Y=$2
printf "\x1b[%s;%sH" $Y $X
}
savepos () { printf "\x1b[s"; }
restorepos () { printf "\x1b[u"; }
typeout () {
S="$1"
for ((x=0;x<${#S};x++)){
printf "\x1b[%s q" $((++K % 6))
printf "%s" "${S:x:1}"
sleep 0.2
}
}
clear
declare -a US
mapfile -t US < <(getent passwd | awk 'BEGIN{FS=":"}$3>1000{print $1}')
LUS=${#US[@]}
for ((Z=0;Z<LUS;Z++)){
XR=$(( (RANDOM % COLUMNS)+ 1))
YR=$(( (RANDOM % LINES) + 1))
savepos
gotoxy XR YR ; printf "\x1b[38;5;%sm" $(( 52 + RANDOM % 140 ))
typeout "${US[Z]}"
printf " \x1b[0m" $(( 52 + RANDOM % 140 ))
restorepos
printf "\b\b\b\b\b%5d" $((LUS-Z))
read -t $(( RANDOM % 1 )) -s -n1 A
[ -n "$A" ] && break
}
let Y=$(( (LINES-5) / 2 ))
declare -i X=0
figlet "$HOSTNAME" |sed -e 's!\\!\\\\!g' | while IFS= read L ; do
[ $X -gt 0 ] || let X=$(( (COLUMNS-${#L}) / 2 ))
gotoxy $X $((Y++)); echo -n "$L"
done
gotoxy 1 $LINES
read -n1 -p "-- Press any key --"
ctrlC
clear