#! /usr/bin/perl # 簡易学会タイマー gakkaitimer.pl Ver.0.2 KITA Toshihiro (http://t-kita.net/) # Vine Linux用。$time1cmd, $time2cmd, $tendcmd を変えれば他でも使える。 # 自由に利用,転載してください。 $time1= 6*60; # 一鈴 $time2= 8*60; # 二鈴 $tend= 12*60; # 終了 # $time1= 1; $time2= 10; $tend= 20; # for testing sounds # コマンドラインの引数に応じて適当に時間設定 if ($#ARGV == 0){ $time1 = $time2 = $tend= $ARGV[0]*60; }elsif ($#ARGV == 1){ $time1= $ARGV[0]*60; $time2 = $tend= $ARGV[1]*60; }elsif ($#ARGV >= 2){ $time1= $ARGV[0]*60; $time2= $ARGV[1]*60; $tend= $ARGV[2]*60; } $time1cmd= "play /usr/share/sounds/phone.wav &"; $time2cmd= "(cd /usr/share/sounds/; play phone.wav; play phone.wav)&"; $tendcmd= "(cd /usr/share/sounds/; play phone.wav; play shutdown1.wav)&"; $|= 1; # auto flush $start= time; system("clear"); while(1){ $elapse= time-$start; # printf("%c[2J",0x1b); # clear screen printf("%c[H",0x1b); # cursor to home printf(" 一鈴: %g分 二鈴: %g分 終了: %g分\n",$time1/60, $time2/60, $tend/60); printf(" 経過時間: %d:%02d 残り時間: %s%d:%02d ", $elapse/60,$elapse%60,((($tend-$elapse)<0)?"-":""), abs($tend-$elapse)/60, abs($tend-$elapse)%60); select(undef,undef,undef,0.1); # 100 msec sleep if ($time1_notyet==0 and $elapse >= $time1 ){ system($time1cmd); $time1_notyet = 1; } if ($time2_notyet==0 and $elapse >= $time2 ){ system($time2cmd); $time2_notyet = 1; } if ($tend_notyet==0 and $elapse >= $tend ){ system($tendcmd); $tend_notyet = 1; } }