--- /dev/null
+#!/usr/bin/perl
+
+use Getopt::Long;
+use Term::ReadKey;
+
+GetOptions(\%options, 'k', 'i', 't');
+
+if(@ARGV > 0) {
+ chdir($ARGV[0]);
+}
+while($dir = <*>) {
+ if(-d $dir) {
+ $fl = {};
+ if(-r "$dir/nextep") {
+ open NE, "$dir/nextep" || die;
+ $ne = "";
+ $ne += $_ while <NE>;
+ close NE;
+ if($ne == 1) {
+ $fl->{"first"} = 1;
+ } else {
+ $fl->{"act"} = 1;
+ }
+ $dirs{$dir} = $ne;
+ if(-r "$dir/.autodl/curep" && -r "$dir/.autodl/rtinfo") {
+ open DE, "$dir/.autodl/curep" || die;
+ $de = "";
+ $de += $_ while <DE>;
+ close DE;
+ if($ne < $de) {
+ $fl->{"hasmore"} = 1;
+ } else {
+ $fl->{"nomore"} = 1;
+ }
+ }
+ }
+ if(-r "$dir/.flags") {
+ open FL, "$dir/.flags" || die;
+ while(<FL>) {
+ chomp;
+ $fl->{$_} = 1;
+ }
+ close FL;
+ }
+ $dirs{$dir} = $fl;
+ }
+}
+if(! -t STDOUT) {
+ die "not on a tty";
+}
+for (keys %dirs) {
+ $cns = $options{"k"} == $dirs{$_}->{"kaka"};
+ # $cns = 0 if $dirs{$_}->{"notdone"} && !$options{"i"};
+ if($cns) {
+ if($dirs{$_}->{"lp"}) {
+ $nc = 31;
+ } elsif($dirs{$_}->{"first"}) {
+ $nc = 32;
+ } elsif($dirs{$_}->{"hasmore"}) {
+ $nc = 36;
+ } elsif($dirs{$_}->{"nomore"}) {
+ $nc = 35;
+ } elsif($dirs{$_}->{"act"}) {
+ $nc = 33;
+ } else {
+ $nc = 34;
+ }
+ } else {
+ $nc = 34;
+ }
+ if($options{"t"} && ($nc == 34)) {
+ delete $dirs{$_};
+ } else {
+ $dirs{$_}->{"color"} = $nc;
+ }
+}
+$cw = 0;
+for $d (keys %dirs) {
+ $l = length $d;
+ $cw = $l if $l > $cw;
+}
+$cw += 2;
+($w, $h) = GetTerminalSize;
+$cols = int($w / $cw);
+@sorted = sort keys %dirs;
+$percol = int(@sorted / $cols) + 1;
+for($i = 0; $i < $percol; $i++) {
+ for($o = 0, $x = 0; $o < $cols; $o++) {
+ $n = ($o * $percol) + $i;
+ last if $n >= @sorted;
+ print (" " x (($cw * $o) - $x)) if $x < $cw * $o;
+ $_ = $sorted[$n];
+ $x = $cw * $o;
+ $nc = $dirs{$_}->{"color"};
+ print "\e[${nc}m$_\e[39m";
+ $x += length;
+ }
+ print "\n";
+}