Clockwork and Mori Integration

Tags ( )

For anyone who might be interested, here is the script I originally developed as a timesheet using Clockwork and Hog Bay Notebook to track my time for project billing. I have adapted the script for use with Mori.

What would help immensely is Clockwork support for logAlarmStart. As far as I can tell, this has yet to be implemented. Please correct me if I am wrong.

-- New Timesheet Entry v0.2
-- Hog Bay Clockwork and Mori AppleScript
-- based on script by Jesse Grosjean
-- by Stephen Bau
-- 03 Feb 2006
using terms from application "Clockwork"

on alarmStarted(anAlarm)
end alarmStarted

on alarmStopped(anAlarm)
my logAlarmStop(name of anAlarm, display time of anAlarm)
end alarmStopped

on selectedTimerDidChange()
tell application "Clockwork"
my logSelectionChange(name of selected timer)
end tell
end selectedTimerDidChange

end using terms from

using terms from application "Mori"

on logSelectionChange(alarmName)
set theEntryName to "Timesheet Entry" & ": " & alarmName as string
tell application "Mori"
tell front document
set eTimesheet to entry named theEntryName
if exists eTimesheet then
tell front document viewer
set current entry to eTimesheet
end tell
end if
end tell
end tell
end logSelectionChange

on logAlarmStop(alarmName, displayTime)
-- Timesheet Entry
set theFolderName to "Timesheets"
set theDate to current date
set theEntryName to "Timesheet Entry" & ": " & alarmName as string
set theNote to "Logged " & theDate as string

tell application "Mori"
tell front document

-- Create Timesheet Folder
if not (exists entry named theFolderName) then
tell root entry
make new entry with properties {name:theFolderName, content type:"public.folder"}
end tell
end if

set theFolder to entry named theFolderName

-- Create Timesheet Entry
if not (exists entry named theEntryName) then
tell theFolder
make new entry with properties {name:theEntryName, note:theNote}
set e to entry named theEntryName
tell e
-- Begin Timesheet Entry
set size of note to 12
set color of note to "gray"

-- startDate
set thisDate to theDate
set dd to text -2 thru -1 of ("0" & thisDate's day)
set mmm to text 1 thru 3 of ((month of (thisDate)) as string)
set yyyy to year of thisDate
set startDate to dd & " " & mmm & " " & yyyy as string
tell e to store custom attribute key "Date" value startDate

-- startTime
set hr to thisDate's hours
set min to thisDate's minutes
set sec to thisDate's seconds
if hr 12 then
copy hr - 12 to hr
end if
end if
if hr = 0 then
copy "12" to hr
end if
if min 12 then
copy hr - 12 to hr
end if
end if
if hr = 0 then
copy "12" to hr
end if
if min

Clockwork and Mori integration with AppleScript?

Alfonso, do you have any plans for extending the integration of Clockwork and Mori to do something similar to what I have attempted to do here with AppleScript? Or did you have something else in mind?

Logging Timer Events

It would appear you use a Clockwork timer to trigger logging events in Mori. Logging timer events is one of the deeper features planned for Clockwork and Mori integration.

Alfonso

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.