unicode precipitation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
638 B

  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use 5.10.0;
  5. use Time::HiRes qw(sleep);
  6. use Term::ReadKey qw(GetTerminalSize);
  7. use File::Slurp;
  8. my @snowflakes = qw(❄ ❅ ❆);
  9. my ($width, $height) = GetTerminalSize();
  10. my $cpu_count = grep { /^processor\s+: [0-9]/ } read_file('/proc/cpuinfo');
  11. while (1) {
  12. my ($load) = (read_file('/proc/loadavg') =~ m/^([\d.]+)/);
  13. my $heaviness = int($load / $cpu_count);
  14. for (0 .. $heaviness) {
  15. my $flake = $snowflakes[ rand @snowflakes ];
  16. say ' ' x int(rand($width)) . $flake;
  17. }
  18. if ($heaviness > 0) {
  19. sleep (1 / $heaviness)
  20. } else {
  21. sleep .75;
  22. }
  23. }