Pomodoro AppleScript

Update – turns out my pomodoro code doesn’t work quite write as published earlier. I think what was happening, was the pomodoro app was compiling the applescript right before it ran it each time, which would continually reset the property value. So, I’ve updated the code below. It now relies on a file (as written below, it’s stored on the desktop, but could be anywhere) to store the comment value. You need to use applescript to create a simple script file called properties.scpt (no, you can’t just do this in a text editor) that contains the following line:

property theRunCount : 0

Set the value to whatever you want to start counting at, minus 1. So if you want the first email to say 1, then set it to 0. Make sure you compile and save the above file, or it’ll give you errors. Yes, the code is much more complicated now. And, if the pomodoro app worked as expected, the earlier version should work perfectly with the property value stored within. 

This is sort of an update to my post on Monday about using pomodoros to stay focused.

I mentioned in that post that I was going to have the pomodoro update my Beeminder graph for me, by sending off an email when a pomodoro completes. I wrote it using AppleScript (which was my first attempt) and it works well. It was hobbled together using some examples I found online for sending email.

--Variables
set recipientName to "Beeminder Bot"
set recipientAddress to "bot@beeminder.com"
set theSubject to "USER/SLUG"
set thedate to day of (current date) as string
set thePropertyScriptPath to (path to desktop folder as string) & "properties.scpt"
set thePropertyScript to load script file thePropertyScriptPath
set thePreviousRunCount to (theRunCount of thePropertyScript)
set theNewRunCount to thePreviousRunCount + 1
set theRunCount of thePropertyScript to theNewRunCount
store script thePropertyScript in file thePropertyScriptPath with replacing

set total to theNewRunCount as string
set theContent to thedate & " 1 " & "\"" & total & "\""
--set x to x + 1
--Mail Tell Block
tell application "Mail"
	--Create the message
	set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
	tell theMessage
		make new to recipient with properties {name:recipientName, address:recipientAddress}
		--Send the message
		send
	end tell
end tell

The only thing this script doesn’t do, is send the name of the pomodoro that finished. I wish I could, because it would make keeping track of them easier (now I end up with a string of identical inputs each day). But, the information doesn’t appear to have been made available to AppleScript. Instead, I recently updated the code so it’s submitting the current pomodoro number. I’d like to do it by day, so each day it’d start from one again, but not sure it’s worth it. The above code is starting with a property value of 14, because I figured this out after completing 13 of them. Unless the code gets recompiled, it will continually increase that property value by one each time it sends off an email. If it gets recompiled and x changes, then it will start from whatever x changes too.

And, as of yesterday evening, after only two days, I’ve already completed 14 pomodoros. Which makes me two ahead of schedule (which is good since I’ve got a bunch of meetings scheduled today). If I manage to stay on track for the semester, Beeminder informs me that I’ll need to complete about 488 in total! Yikes! It’ll be interesting to see how long I stay on target…

Advertisements

7 thoughts on “Pomodoro AppleScript

  1. Pingback: Beeminder Error in Your Favor, and Other Crashes of Ineptitude | Beeminder Blog

  2. Thanks for sharing. I just adapted your script to send the pomodoro name from the Pomodoro Desktop 0.31 by Landini (http://pomodoro.ugolandini.com) End script, which seems to work fine:

    set recipientName to “Beeminder Bot”
    set recipientAddress to “bot@beeminder.com”
    set theSubject to “accountname/pomodoro”
    set thedate to day of (current date) as string
    set theContent to thedate & ” 1 ” & “\”” & “$pomodoroName” & “\””
    –Mail Tell Block
    tell application “Mail”
    –Create the message
    set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
    tell theMessage
    make new to recipient with properties {name:recipientName, address:recipientAddress}
    –Send the message
    send
    end tell
    end tell

  3. Pingback: Beeminder API | Beeminder Blog

  4. Pingback: Another Press Roundup Part Deux, Revisted: Return of the Beeminder Buzz Returns Again! | Beeminder Blog

      • Has the program’s author disappeared/stopped responding to e-mail? Would it be inappropriate to share existing copies, such as my own?

        By the way, I added to the above script so that it plays ambient music for pomodoros and pop music for breaks.

Join the discussion

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s