Live data from Hacker News

Show HN: Bash Screensavers

github.com

81–82 of 82 posts

Re: Show HN: Bash Screensavers

#81
post #79

Earlier quoted context omitted.

With "matrix" causing bash to consume 46% of my CPU time, I think I'll pass. I think I can play the actual film in 4K with less CPU time than that.

Hm, does caching the result of each unique `tput` fix that?

I don't see any `tput`s inside the Main loop. Only at startup and exit. Comment at the top of my version (HEAD as of yesterday) says:

  # This version is optimized for speed by:
  # 1. Using direct ANSI escape codes instead of forking `tput` for every update.

Re: Show HN: Bash Screensavers

#82

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

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.

yeah hn blocks the square rectangle character
Post reply on HN