The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Timer Script - useful for 2 Minute Timer (uses Growl and TimeBoxed) Thread Tools Search this Thread Display Modes
I've created a basic timer script, which uses Growl and TimeBoxed.

The script is useful as a two-minute timer, but it will also use the time estimate value if you've entered one in OmniFocus. When run, the script pops up a sticky Growl bubble with the name of the selected action, and starts a timer countdown in TimeBoxed. This helps me stick to the 2 minute rule and stay focused on the task at hand.

I can't take much credit for this – all I've done is combine two scripts – but I wanted to share it in case anyone else might find it useful.

This is basically a combination (with modifications) of curt.clifton's "What Are You Doing?" script, and Lutin's "TimeBoxed / OmniFocus" script.

I didn't spend too much time hunting down an icon, the one I'm using is from here: http://kylesteed.com/2009/new-clock-icon/

The script will look for an estimated time in the selected action, and if there is an estimated time, it will use that value for the timer rather than the default 2 minutes. You can also change the default timer of 2 minutes to something else by editing the value near the top of the script.

Even if you have multiple items selected, the script will only look at the first item. One thing at a time! :)


I would recommend putting this in your Toolbar and/or setting up a keyboard shortcut for it.

I also recommend changing where the sticky Growl notifications show up on-screen to differentiate them from other Growl notifications. You can do this after running the script once, from Growl's preference pane.

To change the location of the notifications, open the Growl preference pane, then click Applications. Choose OmniFocus Stickies. Then select a custom starting position. I've selected the bottom left.

While you're there, you may also want to click over to the Notifications tab and set Stay On Screen to Always just to be sure.


Please post here if you run into any problems. You will need Growl and TimeBoxed installed for the script to work.
Attached Thumbnails
Click image for larger version

Name:	timer-script-preview.png
Views:	1368
Size:	113.0 KB
ID:	1409  
Attached Files
File Type: zip OmniFocus Timer Script 0.1.zip (34.3 KB, 1256 views)
 
Very nice. Thanks for sharing!
__________________
Cheers,

Curt
 
Thanks. This is awesome.

I've been using it for a week and it really helps things.

Today, and issue cropped up and I'm hoping those with Applescript knowledge can help me out. (I don't know where to begin troubleshooting.)

Now, for some reason, when I try to use the script from the OF toolbar, I get the following error kicked over from Applescript: "File TimeBoxed wasn’t found." However, when I use the script via the AS menu: I get no error; the timer starts; but the timer is not set to the time estimate value, instead it remains whatever it was set at previously (manually).

The growl notification seems to work via either method.

Any advice?
 
I am using this lightly edited version from the toolbar without any problem. Worth a try ?

Code:
-- Light Edit by RT Nov 1 2010
(*
	OmniFocus Timer Script
	
	Version 0.1, by Scott Reeves
	
	The script displays a sticky Growl notification with the selected action from OmniFocus,
	and starts a timer in TimeBoxed, by default 2 minutes. If you've entered a time estimate,
	that value will be used for the timer length.

	Useful as a 2 minute timer, as well as a timer for tasks where you've entered a time estimate.
	
	Scroll down a bit to change the default timer setting to something other than 2 minutes.
	
	Credits:
	Curt Clifton's "What Are You Doing?" script: http://forums.omnigroup.com/showpost.php?p=61416&postcount=18
	Guillaume Cerquant's "TimeBoxed / OmniFocus" script: http://forums.omnigroup.com/showthread.php?t=11859

	Icon from http://kylesteed.com/2009/new-clock-icon/
	
	Version 0.1: Original release
*)

-- Original credits from Curt's script retained
(*
	What Are You Doing?
	
	This script uses Growl to display a sticky note about what you are supposed to be focusing on.
	
	version 0.1, by Curt Clifton
	
	Copyright © 2007-2008, Curtis Clifton
	
	All rights reserved.
	
	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
	
		• Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
		
		• Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
		
	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
	
	version 0.1: Original release
*)

-- Default timer setting if no time estimate is provided (default 2 minutes)
property defaultTimeInMinutes : 2

(*
	The following properties are used for script notification via Growl.
*)
property growlAppName : "OmniFocus Stickies"
property notification : "Stick it"
property defaultNotifications : {notification}
property allNotifications : defaultNotifications
property iconLoaningApplication : "OmniFocus.app"

tell application "OmniFocus"
	tell front document
		tell document window 1
			set taskNote to ""
			
			try
				set lstValue to (value of selected trees of content)
				set oTask to first item of lstValue
			on error
				display alert "Please select an item to work on first." as warning
				return
			end try
			
			-- start out with the default value
			set taskMinutes to defaultTimeInMinutes
			
			tell oTask
				-- update to estimated time if it's set
				if estimated minutes > 0 then
					set taskMinutes to estimated minutes
				end if
				
				set taskTitle to name
				set taskNote to note
			end tell
			
			if taskMinutes > 0 then
				my notify("What are you doing?", taskTitle, notification)
				my startTimer(taskMinutes * 60)
			end if
			
		end tell
	end tell
end tell

(*
	Uses Growl to display a notification message.
	theTitle – a string giving the notification title
	theDescription – a string describing the notification event
	theNotificationKind – a string giving the notification kind (must be an element of allNotifications)
*)
on notify(theTitle, theDescription, theNotificationKind)
	tell application "GrowlHelperApp"
		register as application growlAppName all notifications allNotifications default notifications defaultNotifications icon of application iconLoaningApplication
		notify with name theNotificationKind title theTitle application name growlAppName description theDescription with sticky
	end tell
end notify

on startTimer(numberOfSeconds)
	tell application id "com.macmation.timeboxed"
		activate
		set timer duration to numberOfSeconds
		reset
	end tell
end startTimer
 
I haven't run a diff on it and I have no idea what you've done, but it works! So glad I asked. Thank you so much!
 
Thanks, Rob. It looks like the
Code:
tell application id "com.macmation.timeboxed"
may be part of what's working better in your script. You also have a far less hacky version of getting the first selected item in the tree. Kudos!
 
Now, if there was only some way to get this to work on an iPad..........
 
I like how Minuteur displays an actual countdown in the menu bar. Here's a modification of Rob's last post to work with Minuteur.

Code:
-- Switched to Minuetur by DNB Dec 13 2010

-- Light Edit by RT Nov 1 2010
(*
	OmniFocus Timer Script
	
	Version 0.1, by Scott Reeves
	
	The script displays a sticky Growl notification with the selected action from OmniFocus,
	and starts a timer in TimeBoxed, by default 2 minutes. If you've entered a time estimate,
	that value will be used for the timer length.

	Useful as a 2 minute timer, as well as a timer for tasks where you've entered a time estimate.
	
	Scroll down a bit to change the default timer setting to something other than 2 minutes.
	
	Credits:
	Curt Clifton's "What Are You Doing?" sc	ript: http://forums.omnigroup.com/showpost.php?p=61416&postcount=18
	Guillaume Cerquant's "TimeBoxed / OmniFocus" script: http://forums.omnigroup.com/showthread.php?t=11859

	Icon from http://kylesteed.com/2009/new-clock-icon/
	
	Version 0.1: Original release
*)

-- Original credits from Curt's script retained
(*
	What Are You Doing?
	
	This script uses Growl to display a sticky note about what you are supposed to be focusing on.
	
	version 0.1, by Curt Clifton
	
	Copyright © 2007-2008, Curtis Clifton
	
	All rights reserved.
	
	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
	
		• Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
		
		• Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
		
	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
	
	version 0.1: Original release
*)

-- Default timer setting if no time estimate is provided (default 2 minutes)
property defaultTimeInMinutes : 2

(*
	The following properties are used for script notification via Growl.
*)
property growlAppName : "OmniFocus Stickies"
property notification : "Stick it"
property defaultNotifications : {notification}
property allNotifications : defaultNotifications
property iconLoaningApplication : "OmniFocus.app"

tell application "OmniFocus"
	tell front document
		tell document window 1
			set taskNote to ""
			
			try
				set lstValue to (value of selected trees of content)
				set oTask to first item of lstValue
			on error
				display alert "Please select an item to work on first." as warning
				return
			end try
			
			-- start out with the default value
			set taskMinutes to defaultTimeInMinutes
			
			tell oTask
				-- update to estimated time if it's set
				if estimated minutes > 0 then
					if estimated minutes > 720 then
						set taskMinutes to 720 --max Minuteur time: 12 hrs
					else
						set taskMinutes to estimated minutes
					end if
				end if
				
				set taskTitle to name
				set taskNote to note
			end tell
			
			if taskMinutes > 0 then
				my notify("What are you doing?", taskTitle, notification)
				set strHMS to my MinuteurString(taskMinutes)
				tell application "Minuteur"
					activate
					StartCountdown strHMS
				end tell
			end if
		end tell
	end tell
end tell

(*
	Uses Growl to display a notification message.
	theTitle – a string giving the notification title
	theDescription – a string describing the notification event
	theNotificationKind – a string giving the notification kind (must be an element of allNotifications)
*)
on notify(theTitle, theDescription, theNotificationKind)
	tell application "GrowlHelperApp"
		register as application growlAppName all notifications allNotifications default notifications defaultNotifications icon of application iconLoaningApplication
		notify with name theNotificationKind title theTitle application name growlAppName description theDescription with sticky
	end tell
end notify

on MinuteurString(lngMinutes)
	set strHoursLeft to (lngMinutes div 60) as string
	if length of strHoursLeft < 2 then
		set strHoursLeft to "0" & strHoursLeft
	end if
	
	set strAdditionalMins to (lngMinutes mod 60) as string
	if length of strAdditionalMins < 2 then
		set strAdditionalMins to "0" & strAdditionalMins
	end if
	
	return strHoursLeft & strAdditionalMins & "00"
end MinuteurString
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
TimeBoxed / OmniFocus applescript Lutin OmniFocus Extras 3 2012-10-19 07:23 AM
Built In 2 Minute Timer? mrubenson OmniFocus 1 for Mac 7 2011-03-23 07:18 AM
1 minute WebDav Setup for Dreamhost Mauronic Other WebDAV 4 2010-03-23 06:42 AM
20 minute startup delay ericob OmniWeb Bug Reports 3 2007-09-18 02:18 PM
Hour/Minute/Second Repeats wkoffel OmniFocus 1 for Mac 3 2007-06-29 05:36 PM


All times are GMT -8. The time now is 07:29 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.