use warnings;
use Term::ANSIColor 2.01 qw(:constants colored);
use Term::Screen;
+binmode STDOUT, ":encoding(utf8)";
-my ($sta,$end) = (time,undef);#my $end = $sta + 15*60;
+
+my ($sta,$end_at) = (time,undef);
my ($time, $cmd);
our @pos = getCPos();
print BOLD "\rTimer:", BRIGHT_BLUE, ON_BRIGHT_BLACK," $title \n", RESET
}
elsif ( $arg =~ /^\d+/ ) {
- $end = $sta + $arg * 60;
+ $end_at = $sta + $arg * 60;
print "\rCountdown set to minutes: $arg\n";
}
elsif ( $arg =~ /^-+t.*/ ) {
$tlo = 1;
}
- elsif ( $arg =~ /^-+f.*/ ) {
+ elsif ( $arg =~ /^-+f.*/ ) {
&fzf;
}
elsif ( $arg =~ /^-+[^0-9]+/ ) {
- $t->at($row-3,0)->clreol();undef $t;
+ $t->at($row-3,0)->clreos(); undef $t;
while (<DATA>) {print transPrint($_)}
exit;
}
return
}
-&fzf unless $end;
+&fzf unless $end_at;
my $stopwatch = time;
my ($tt, $ptime, $stoptime, $tc,$cur,$sur) = 0;
my ($stop,$stop_countdown) = (0,0);
-$t->at($row, 0)->curinvis(); die "Time not specified!" unless $end;
+die "Time not specified!" unless $end_at;
+
+$t->at($row, 0)->curinvis();
while() {
$time = time;
- last if ($time > $end);
+ last if ($time > $end_at);
- $cur = $end - $time unless $stop_countdown;
+ $cur = $end_at - $time unless $stop_countdown;
$sur = $time - $stopwatch unless $stop;
$t->flush_input();
$t->clreol();
my $stmp2 = sprintf(" [%02d:%02d:%02d]", $sur/(60*60), $sur/(60)%60, $sur%60);
$stmp2=~s/^\d//;
+
if (($cur/(60)%60)>1){
- print YELLOW "\rTimer-> ", ON_BRIGHT_BLACK, BOLD, CYAN, " $stmp1 ", RESET, GREEN, $stmp2, RESET unless $stop_countdown;
+ print YELLOW "\rTimer \x{2015}\x{2AAB} ", ON_BRIGHT_BLACK, BOLD, CYAN, " $stmp1 ", RESET, GREEN, $stmp2, RESET unless $stop_countdown;
}else{
$tc=0 if $tc++>3;
if (($cur%60)<2){
- print BOLD, GREEN, "\rTIMER ", "---> ", $stmp1, RESET, GREEN, $stmp2, RESET;
+ print BOLD, GREEN, "\rTIMER ", "\x{2015}\x{2015}\x{2015}\x{2AAB} ", $stmp1, RESET, GREEN, $stmp2, RESET;
}else{
- print RED "\rTimer ", BOLD;
- if($tc==0){print YELLOW, "-", RED, "--"}
- elsif($tc==1){print "-", YELLOW, "-", RED, "-"; print chr(7)}
- elsif($tc==2){print "--", YELLOW, "-"}
- else{print "---", YELLOW}
- print "> ", RED, $stmp1, RESET, GREEN, $stmp2, RESET;
+ ($tc>0?print RED:print YELLOW); print "\rTimer ", BOLD;
+ if($tc==0){print YELLOW, "\x{2015}", RED, "\x{2015}\x{2015}"}
+ elsif($tc==1){print "\x{2015}", YELLOW, "\x{2015}", RED, "\x{2015}"; print chr(7)}
+ elsif($tc==2){print "\x{2015}\x{2015}", YELLOW, "\x{2015}"}
+ else{print "\x{2015}\x{2015}\x{2015}", YELLOW}
+ print "\x{2AAB} ", RED, $stmp1, RESET, GREEN, $stmp2, RESET;
}
}
$stop_countdown =$stop_countdown?0:1; $stop=0;
print RED, BLINK, " Countdown -> ".($stop_countdown?"Paused":"Running")."!", RESET;
if($stop_countdown){$stoptime = time}
- else{$end += time - $stoptime;}
+ else{$end_at += time - $stoptime;}
}else{
$stop = $stop?0:1;
print RED " Stopwatch -> ".($stop?"Paused":"Running")."!";
}
}
-$t->curvis()->normal()->clreol();$title=$$ unless $title;
+$t->curvis()->normal()->clreol(); $title=$$ unless $title;
my $msg = "Timer '$title' has expired!";
`/usr/bin/notify-send "TIMER $title" "$msg"&`;
$ptime = `date '+%r'`; $ptime =~ s/\n$//;
-print BRIGHT_RED, BLINK, "\r$msg [ $ptime ]\n", RESET;
+$t->at($row+1,0)->clreos()->curvis()->clreol();
+print BRIGHT_RED, BLINK, "\r$msg [ $ptime ]", RESET;
if($cmd){
- $t->echo();
- system('echo "\e[?25h"');
- print YELLOW "\rResult of ->`".$cmd, "` is:\r\n";
+ $t->echo();
+ $t->at($row+1,0);
+ system('echo "\e[?25h\b"');
+ print YELLOW "Result of \x{2015}\x{2AAB} `".$cmd, "` is:\r\n";
my @res = qx/$cmd/;
foreach my $l(@res){
$l =~ s/\n*$//;
}else{ #MODIFY BELLOW TO DESIRED ALARM, or move the provided ./chiming-and-alarm-beeps.wav to your Music folder.
system("mpv --vid=no --loop-file=3 $ENV{HOME}/Music/chiming-and-alarm-beeps.wav > /dev/null");
$row-=5 if $row>$t->rows();
- $t->at($row+1, 0)->clreol()->at($row, 0); print BRIGHT_RED, "\r$msg [ $ptime ]", RESET;
+ $t->at($row+1, 0)->clreol()->at($row, 0)->clreol(); print BRIGHT_RED, "\r$msg [ $ptime ]", RESET;
system('echo "\e[?25h"');
$t->dl()->at($row+1, 0)->clreol()->echo()->curvis();
}
if($sel =~ m/m$/){
$sel =~ s/m$//;
print "Setting timer($$) to $sel minutes.\n";
- $end = $sta + $sel * 60;
+ $end_at = $sta + $sel * 60;
}
elsif($sel =~ m/h$/){
$sel =~ s/h$//;
print "Setting timer($$) to $sel in hours.\n";
$sel *= 60;
- $end = $sta + $sel * 60;
+ $end_at = $sta + $sel * 60;
}elsif($sel =~ m/s$/){
$sel =~ s/s$//;
print "Setting timer($$) to $sel in seconds.\n";
- $end = $sta + $sel;
+ $end_at = $sta + $sel;
}
else{
exit 1;#<- should not be possible!
- }
+ }
}else{
exit;
- }
+ }
return $t->at($row-=5, 0)
}
sub interupt {
$exited=1;
system('echo "\e[?25h"');#sleep 1;
$row+=1;
- $t->at($row, 0)->clreos()->echo()->curvis();
+ $t->at($row, 0)->clreol()->echo()->curvis()->normal()->clreos();
print RESET, "[CTRL]+[C] <- Terminated!\r\n";
exit 0;
};