-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathi3blocks-prettycrontab
More file actions
executable file
·49 lines (46 loc) · 1.08 KB
/
i3blocks-prettycrontab
File metadata and controls
executable file
·49 lines (46 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env perl
use 5.020_000;
use warnings;
use open qw<:std :utf8>;
use utf8;
my $RX_LINE = qr{
\A
(?<deltaseconds> \d+ )
\t
(?<rest> .+ )
\z
}xms;
my @lines = qx!crontab -l | prettycrontab -deltaseconds -deltacoarse -timestamp=0!;
chomp @lines;
if (!@lines) {
say '';
exit 0;
}
my @munged;
for my $line (@lines) {
if ($line =~ $RX_LINE) {
my ($deltaseconds, $rest) = ($+{deltaseconds}, $+{rest});
$rest =~ s!\s+! !xmsg;
if ($deltaseconds > 1800*3) { # Don't show me stuff that's WAY away.
next;
}
elsif ($deltaseconds < 180) {
push @munged, qq!<span fgcolor="#ddda00">$rest</span>!;
}
elsif ($deltaseconds < 300) {
push @munged, qq!<span fgcolor="#dd9900">$rest</span>!;
}
elsif ($deltaseconds > 1800) {
push @munged, qq!<span fgcolor="#999999">$rest</span>!;
}
else {
push @munged, $rest;
}
}
}
say join ' · ', @munged;
for (@munged) {
s!\smins\s!m !xmsg;
}
say join ' · ', @munged;
exit 0;