←back to thread

225 points attogram | 1 comments | | HN request time: 0.001s | source

A github project to collect a bunch of bash-based screensavers/visualizations.
Show context
dorianmariecom ◴[] No.45738518[source]
a simple one:

    #!/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
    done
replies(1): >>45739772 #
1. axiolite ◴[] No.45739772[source]
Just an empty screen here... You're picking random positions on screen, and random colors, but then you don't display ANY text so the info is discarded and cells remain clear.

After 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.