Posted by attogram 1 day ago
[1]: https://en.wikipedia.org/wiki/ANSI_escape_code#Control_Seque...
A lot of screensavers, even historically, forget the original purpose of what "saving" your screen means.
#!/usr/bin/env bash
_cleanup_and_exit() {
tput cnorm
tput sgr0
clear
exit 0
}
trap _cleanup_and_exit SIGINT
while true; do
width=$(tput cols)
height=$(tput lines)
tput setab 0
clear
tput civis
x=$((RANDOM % width + 1))
y=$((RANDOM % height + 1))
color_code=$((RANDOM % 256))
printf "\e[${y};${x}H\e[38;5;${color_code}m"
sleep 1
doneAfter the printf, perhaps you want: tput smso; echo -n " "
Then I find moving the second "clear" before the "while" makes it more interesting. Not sure if that's more like what you intended.