TagTime Hack on iOS using AppleScript

I’ve created this AppleScript, which I’ve saved as an application and set to begin running as soon as I log in.

It uses the same formula as TagTime (I believe) for selecting the time between pings (though, it won’t ping at the same time as everyone else the way the other hacks do). It then sends me an email prompting me to respond to the tag. (I have the email it comes from set up as the only VIP email address, and set to push, so I get notified of these emails very shortly after they come in, but not notified of other emails, which I would find distracting, since I prefer to answer my emails only a couple of times per day (week?).)

The email also has a link to a Workflow (here’s the app: https://itunes.apple.com/us/app/workflow-powerful-automation/id915249334?mt=8 ) that asks me for what I’m doing (the 1-word tag) and constructs and sends an email to Beeminder with my response. (I’m not going to include info about the workflow here, because I think it’s likely that people will prefer to customize their own response to the tag, but let me know if you’d like more details about mine.)

Anyway, here’s the script for the application:

	set r to (random number from 0.0 to 1.0) # U[0,1] random variable
	set w to (do shell script ("echo '-45*60*l("&(r as string)&")'|bc -l")) as real
	delay w # wait for -45*60*log(r) seconds
	do shell script "afplay /System/Library/Sounds/Glass.aiff"
	say "Ping!!"
	set nom to "YOUR NAME" #CHANGEME
	set subj to "It's TagTime!"
	set body to "Run the TagTime Workflow: MYWORKFLOWLINK" #CHANGEME
	tell application "Mail"
		set msg to make new outgoing message with properties ¬
			{subject:subj, content:body, visible:true}
		tell msg
			make new to recipient with properties {name:nom, address:addr}
			send # actually send the email
		end tell
	end tell
end repeat

Thanks so much for posting this, @mary! I just noticed that, due to your discretization of the U[0,1] random numbers – (random number from 0 to 1000)/1000 – there’s a 0.1% chance of it picking exactly zero and deciding to wait … let’s see… 8 quadrillion years for the next ping. Not sure why the bc program thinks log of zero is finite, but whatever. Anyway, that’s a 0.1% chance each time so it won’t take long (a month, I guess) for that to actually happen.

I believe you can fix it like so: set randomNumber to random number from 0.0 to 1.0

Or @alice may have a better way to do this altogether.

Thanks @dreev

1 Like

Cool, I wikified your post and made the change here as well. Now I’m tempted to go crazy refactoring it…

PS: I cleaned up the code a bit more. For example, I didn’t have the “Play Sound” app so I replaced that with a command line sound player that should be more standard.

1 Like

Hi. Small question for mortals. How do I install this script as an application on my phone? Does it need to be jailbroken?

1 Like

I think this is meant to be run on OSX and just generate email that you’ll see on iOS.

1 Like