2 #MoonPhase-Applet (Harvie 2oo9)
9 my $icons = '/usr/share/icons/moonphase-icons'; #directory with moon phase icons
13 my $days = int($t/(60*60*24)); $t %=(60*60*24);
14 my $hours = int($t/(60*60)); $t %=(60*60);
15 my $mins = int($t/(60)); $t %=(60);
16 return $days."d ".$hours."h ".$mins."m ".$t."s";
20 my $statusicon = Gtk2
::StatusIcon
->new();
21 #$statusicon->signal_connect(activate => sub { Gtk2->main_quit; }); #exit on click...
23 opendir(my $dir,$icons);
24 my @filenames = readdir($dir);
27 @filenames = sort(@filenames); shift(@filenames); shift(@filenames); #remove . and ..
28 #@filenames = sort(sub {$b cmp $a}, @filenames); pop(@filenames); pop(@filenames); #reversed
30 my @phase_name = ("NEW MOON", "FIRST QUARTER", "FULL MOON", "LAST QUARTER");
34 return int(( (($r*@filenames)+.5)%@filenames )+.5);
38 if($ARGV[0] eq '--rotate') {
42 my $img = "$icons/".$filenames[imgno
($i/100)];
43 my $inf = "$i%\t$img";
44 $statusicon->set_from_file($img);
45 $statusicon->set_tooltip_text($inf);
55 my $time = time(); #seconds_since_1970
56 my ($MoonPhase, $MoonIllum, $MoonAge, $MoonDist, $MoonAng, $SunDist, $SunAng) = phase
($time);
57 #$MoonPhase = ($MoonPhase+0.5)%1;
58 #my $imgno = int(( (($MoonPhase*@filenames)+.5)%@filenames )+.5);
59 my $imgno = imgno
($MoonPhase);
60 my $img = $filenames[$imgno];
63 my ($phase, @times) = phaselist
(time(), (time()+60*60*24*31));
65 my $phasetime = shift(@times);
66 $prediction .= "$phase_name[$phase] coming at:\n ".scalar(localtime($phasetime))." (".timediff
($phasetime-$time)." remaining)\n";
67 $phase = ($phase + 1) % 4;
70 my $tooltip = "Astro::MoonPhase Applet (by harvie 2oo9)\n".
71 "Local time is: ".scalar(localtime($time))."\n\n".
73 "MoonPhase = ".($MoonPhase * 100)." %\n".
74 "MoonIllum = ".($MoonIllum * 100)." %\n".
75 "MoonAge = $MoonAge days\n".
76 "MoonDist = $MoonDist km\n".
77 "MoonAng = $MoonAng degrees\n".
78 "SunDist = $SunDist km\n".
79 "SunAng = $SunAng degrees\n".
80 "Icon = $img ($imgno/".scalar(@filenames)." images total)\n\n".
81 "See man Astro::MoonPhase for explanation\n".
82 "Tip: You can make fullmoon gathering with friends each month.\n";
85 print "\033[2J\033[0;0H$tooltip";
87 $statusicon->set_tooltip_text($tooltip);
88 $statusicon->set_from_file($img);
This page took 0.525349 seconds and 4 git commands to generate.