Browse Source

now with more dependencies!

pull/1/head
Brennen Bearnes 9 years ago
parent
commit
090610c876
1 changed files with 12 additions and 6 deletions
  1. +12
    -6
      wthr

+ 12
- 6
wthr View File

@ -4,20 +4,26 @@ use strict;
use warnings;
use 5.10.0;
use Time::HiRes qw(sleep);
use Term::ReadKey qw(GetTerminalSize);
use File::Slurp;
my ($width, $height) = GetTerminalSize();
my @snowflakes = qw(❄ ❅ ❆);
my ($width, $height) = GetTerminalSize();
my $count //= grep { /^processor\s+: [0-9]/ } read_file('/proc/cpuinfo');
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 / $count) * $width);
my $heaviness = int($load / $cpu_count);
for (0 .. $heaviness) {
say ' ' x int(rand($width)) . ($snowflakes[ rand @snowflakes ]);
my $flake = $snowflakes[ rand @snowflakes ];
say ' ' x int(rand($width)) . $flake;
}
if ($heaviness > 0) {
sleep (1 / $heaviness)
} else {
sleep .75;
}
sleep 1;
}

Loading…
Cancel
Save