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

#!/usr/bin/env perl
use strict;
use warnings;
use 5.10.0;
use Time::HiRes qw(sleep);
use Term::ReadKey qw(GetTerminalSize);
use File::Slurp;
my @snowflakes = qw(❄ ❅ ❆);
my ($width, $height) = GetTerminalSize();
my $cpu_count = grep { /^processor\s+: [0-9]/ } read_file('/proc/cpuinfo');
while (1) {
my ($load) = (read_file('/proc/loadavg') =~ m/^([\d.]+)/);
my $heaviness = int($load / $cpu_count);
for (0 .. $heaviness) {
my $flake = $snowflakes[ rand @snowflakes ];
say ' ' x int(rand($width)) . $flake;
}
if ($heaviness > 0) {
sleep (1 / $heaviness)
} else {
sleep .75;
}
}