DQdlM
DQdlM

Reputation: 10254

Silent timer alert for perl timer - something like a "visual bell"

I use the pomodoro technique to manage my time and so I have written this short timer in perl. However, since I work around other people, I can't use an audible bell when the time runs out and since the timer is often in the background behind the window I am working in, I can't see when it finishes.

Is there a way to make a simple visual signal when the timer ends? My first thought would be something that would just bring the window to the foreground but I am not sure how to do this. However, any other suggestions are welcome.

I am running Xubuntu with fluxbox as my window manager. The timer is running in the Xfce terminal emulator.

Thanks

#!/usr/local/bin/perl

 use warnings;
 use strict;

 print "Enter minutes \n";
 my $min;
 my $n;

 $min = <STDIN>; # number of minutes to time
 chomp $min;
 for ($n = $min; $n >= 1; $n--){ # counts down the number of minutes
 print "$n minutes remaining\n";
 sleep(60); # counts down 60 seconds
 }
 print "*********************\n";
 print "*********************\n";
 print "* Minutes elapsed = $min \n";
 print "*********************\n";
 print "*********************\n";

Upvotes: 1

Views: 367

Answers (1)

tJener
tJener

Reputation: 2619

I think you can use notify-send, which uses libnotify, to give you notifications. Its designed to be used with scripts, and this use case seems to fit very well.

Upvotes: 1

Related Questions