#!/usr/bin/perl # ---------------------------------------------------------------------- # EYEBREAK STOP -- PERL PROGRAM # ---------------------------------------------------------------------- # This program will display a dialog every 20 minutes to remind you # to take a break. # ---------------------------------------------------------------------- $opt_pidfile = "$ENV{HOME}/.eyebreak.pid"; # ---------------------------------------------------------------------- # Use GetOptions to parse the command line options... use Getopt::Long; $autoabbrev=1; $result = GetOptions("pidfile=s", "stop", "help", "debug"); if ($opt_help or !$result) { print "Running this program will attempt to stop an already running\n"; print "Eye Break program.\n"; exit; } # ---------------------------------------------------------------------- # MAIN PROGRAM LOGIC # ---------------------------------------------------------------------- use MacPerl; use Mac::Speech; if (-e "$opt_pidfile" and -r "$opt_pidfile") { open (P, $opt_pidfile) or die "Can't read $opt_pidfile: $!\n"; my $otherPID =

; close(P); open (S, "ps -p $otherPID -o ucomm |"); my $ignore_header = ; my $command_line = ; close(S); if ($command_line =~ /perl/) # We have a live process running { kill "USR1", $otherPID; } else { SpeakString("Eye break doesn't seem to be running."); sleep 1 while SpeechBusy(); # Wait for the voice to stop } } else { SpeakString("Eye break doesn't seem to be running."); sleep 1 while SpeechBusy(); # Wait for the voice to stop }