Okay. I'll paste it in below. Below that, I'll give instructions for extracting the pasted text and making it a file.
in case this grou *WILL* allow attachments, I ahve also attached it; if you don't know how to get the attachment to where you want it, contact me and I'll explain that too.
Okay. There is a line of stars (*) and then the text of the program, and then another lines of Stars (*), and then buletted (YAY) instructions after that. So, off we go then: ************ #!/bin/bash # Commented version, merged between yours and my second version, # and cleaned up a little. # All comments begin with a # # If the number of arguments given to timer is not equal to 3 # then do the next few statements until the else if [ $# -ne 3 ] then # say some stuff about using the defaults echo "Usage: timer [interval in seconds] [end time in minutes] [number of loops]" echo "Using default interval 300 seconds(five minutes), total time 30 minutes, 2 loops" # set the defaults # this is where you were getting the 20 minutes on the other script, # because its check was less than 2 arguments # in seconds waitTime=180 # in minutes endTime=15 # just a count loops=4 # otherwise else # use the argments the user gave # $1 is the first argument, $2 the second, and $3 the third waitTime=$1 endTime=$2 loops=$3 # finish the if statement fi # Do not modify below this line unless # you know what you are doing. # Set up 4 default variables to keep track of the seconds and loops # will be used to count seconds within each cycle/iteration loop that have been done totalSeconds=0 # The next line of code does lots of stuff, detailed in the paragraph below # which all together basically say "multiply the variable by 60", # which calculates the end time in seconds from the minutes the user gave # because my loops work in seconds. # Broken down and explained in parts: # The backticks enclose another command, the results of which are stored in # The variable endTimeInSeconds. # The echo sends text back to the screen. # $endTime gets replaced by the number of minutes the script is using # (default 20 or user provided). # *60+1 are sent to the screen as they are. # | is the pipe which takes the screen's text that was supposed to get # displayed and redirects it to the following command. # bc - An arbitrary precision calculator language. # in the terminal, at the prompt, type man bc # which will display the manual for bc. # You can do this for most all commands. endTimeInSeconds=`echo $endTime*60 | bc` # Will be used to count interval seconds within each loop that has been done. # resets to 1 each iteration/cycle loop totalSecondsInIteration=0 # Used to keep track of how many times the user has been notified within the cycle. # (using base 1 instead of base 0 so when the script speaks the count, it starts at 1) # (most counting in programming starts at 0) totalIterationCount=1 # Will be used to count loops that have been done totalLoops=0 # While the number of loops that have been done (totalLoops) is not equal to # the number of loops the script is using, do the commands that are between # the do and done lines. # The ! means NOT. #first sleep 30 seconds to give time to get set up, then plays a sound. echo "Counting down to start." sleep 30 afplay ~/sounds/electronicping.wav while [ ! "$totalLoops" = "$loops" ] do # While the total seconds that have been done is not equal to the number # of seconds desired per cycle/iteration, do the commands that are between # the do and done lines. while [ ! "$totalSeconds" = "$endTimeInSeconds" ] do # This is just a debugging line to see if I have all the counts right, which prints # to the screen. # Add a # to comment it out so it doesn't display. # Or remove the # at the beginning of the line to make it display. #echo "totalSecondsInIteration:$totalSecondsInIteration waitTime:$waitTime totalSeconds=$totalSeconds endTimeInSeconds=$endTimeInSeconds" # If the number of seconds that have been done equals the number of seconds # we want to be done, run the commands between the then and fi. if [ "$totalSecondsInIteration" = "$waitTime" ] then # Notify the user. # Speak the count of seconds that have been done. # The & sends the command into the background so the script # can continue, which makes the script more accurate on its seconds. # You'll get some whacky results if the time it takes to complete # the command is longer than the time it takes to do your desired loop. #say "$totalIterationCount" & # Calculate the percentage complete. percentDone=`echo "$totalSeconds*100/$endTimeInSeconds" | bc` # Speak the percentage complete. say $percentDone" percent" & # Play a sound. afplay ~/sounds/electronicping.wav & # Reset the number of seconds that have been done this iteration. totalSecondsInIteration=0 # Increment the count of notifications to the user. totalIterationCount=`echo $totalIterationCount+1 | bc` fi # Increment the seconds that have been done this iteration. totalSecondsInIteration=`echo $totalSecondsInIteration+1 | bc` # Increment the total seconds that have been done. totalSeconds=`echo $totalSeconds+1 | bc` # Make the script wait 1 second before continuing. sleep 1 done # reset all the cycle variables totalSeconds=0 totalSecondsInIteration=0 totalIterationCount=1 # increment the number of loops that have been done totalLoops=`echo $totalLoops+1 | bc` # notify the user that a complete cycle has occurred. afplay ~/sounds/foghorn2.wav & say "End Loop $totalLoops" & done # Delay long enough to play the last loop's notification. sleep 2 # notify the user that the script has ended say "All done" *************** Here are instructions for extracting that and saving it as a file which will work from Finder ot Terminal: •1) Select/highlight all the text between the stars, but not including the stars, and copy it to the pasteboard. (If you need further help with this, tell me off list). •2) Open TextEdit and paste the contents of the pasteboard into a new file. Save this new file to whatever directory in your home directory you will be most comfortable finding it in. For this post, I will assume you saved it as "timer." There is no extension necessary. •3) Carefully determine the exact path to the newly saved Timer file. On my machine, this past looks like ~/timer Because I save it on the root of my home directory (NOT the root directory for the machine!). Once you know the exact path to the file, proceed: •4) Open Terminal. If you need more help with this, contact me off list. Once a Terminal window opens, type the following: Chmod 755 (the exact path to the Timer file.) On my machine, this would look like: Chmod 755 ~/timer •5) This timer will not only count down, but it plays a sound at certain intervals within the main count-down sequence. It was designed to count intervals while working out, but can also be used to time stuff in the oven, your toenails growing, whatever. Thus, you need to tell it how many second each interval will be, how long the entire count-down runs for, and how many count-downs you want. For experienced programmers, those values can be set from within TextEdit (contact me for more details on this). •6) As I sent Timer, it is set up to beep every 3 minutes until 15 minutes have been counted, then play another sound. It occurs to me that you don't have the wave files that play these sounds, so you will have to substitute them in the "Afplay" statement within the script, or the thing will crash. •7) The easiest way to start the timer is to open a Terminal window and type "./(pathname)." Thus, I would type "./timer" If you wish to change the defaults, you may enter the new values for interval time, count-down time and number of count-downs by entering the number of intervals (seconds), total time to count down (minutes) and number of times to do the total count-down (also minutes). Thus, if I wanted to change my timer to count down for one hour, giving me four intervals of 15 minutes, for a total of four hours, I would type, from within the Terminal window: .timer 900 60 4 900 seconds in 15 minutes, 60 minutes in an hour, 4 hours total timing. •8) Remember that if you do not set different values, Timer wil use the defaults, which might give you a different timing result than you want. •9) you may also find the file through Finder and simply press Command O to open it, however this method will not give you the option to reset the defaults. •10) If you wish to modify this Timer, for example you will need to do so to put in your own sounds (contact me off list and I will send the wave files *I* use, but you are encouraged to use your own), highlight the file in Finder and then, from the File menu, choose "open with," and then "other," and "textEdit.app" from the menu that pops up. After you are done modifying it in TextEdit, make sure that, when you save it, make sure that there is no ".rtf," extension tacked on by TextEdit, as it wants to do that unless you tell it not to. Again, write me off list if you need help with that. •11) Enjoy your new, very flexible timer! Again, thanks to Theresa Ford for writing the thing, she deserves full credit. • Mark BurningHawk Baxter • AIM, Skype and Twitter: BurningHawk1969 • MSN: burninghawk1...@hotmail.com • My home page: • http://MarkBurningHawk.net/
timer
Description: Binary data
-- You received this message because you are subscribed to the Google Groups "MacVisionaries" group. To post to this group, send email to macvisionaries@googlegroups.com. To unsubscribe from this group, send email to macvisionaries+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/macvisionaries?hl=en.