TimeTrackingTicToc

TicToc is a simple yet feature-full app that sits in your menubar and tracks time on various projects/tasks. Later it is possible to export the time tracks to an assortment of formats.

Since I already do some time tracking with TicToc, I thought it would make sense to integrate the two.

This is therefore a first draft of what I hope will become a more feature-full little script.

Features (so far)

Usage

Before the first run it is important you customize the script with your preferred tags.
- @tictoc is the default "tracking" tag. The Value of this tag has to be the name of your task in TicToc.

Take for instance:

I would then have to have tasks in TaskPaper as:

- Complete readme.md for script @tictoc(TaskPaper Timetracking)
- Complete some random test @tictoc(test)

NOTE: This is case insensitive so no need to be too fussy ;)

Errors

In this first version, the script will output errors in the following situations:
- Entry selected is not a task; - Entry selected doesn't have a tracking tag (@tictoc default); - Tracking tag is either empty or it's value doesn't correspond to a task/event in TicToc

Tips and Tricks

A good use is to create a Task/Event in Tictoc with the same name as the project, or smaller aspects of the project. Say we have a project in TPM named Create Website. That can be broken down into various tasks, some relating to design, others to coding etc. We could have to events in TicToc named Design and another named Development, so...

Create WebSite:
    - Mockup initial ideas @tictoc(Design)
    - Email mockup and get approval @tictoc(Design)
    .....
    - Code base HTML @tictoc(Development)
    - Code CSS @tictoc(Development)
    ... (you get the idea ;) )

This would them allow you breakdown and analyze exactly how much time each part of the process took.

Caveats

Support

I've setup a github page for this so I ask that if you find any errors please file a issue over at github.

The Script


    --  TaskPaper Actions   
    -- 
    --  For use with TaskPaper, TitToc and Alfred
    --  For further instructions read the README.md or visit http://palobo.tumblr.com
    --
    --  Copyright (C) 2012  Pedro Lobo <palobo@gmail.com>
    --

    -- Set your variables here
    set trackTag to "tictoc" -- Tag used for timetracking. Must have following format @tag(EVENT NAME IN TICTOC)
    set runningTag to "running" -- Tag used to show a task is being tracked/timmed
    set extraInfo to {{extraName:"doc", extraPath:""}, {extraName:"outline", extraPath:""}} -- Tag used for storing/accessing doc with further info

    -- Growl Support. Set to True after first use. Needed to register with Growl first time round
    set registered to "False"

    -- Change nothing bellow this point unless you know what you're doing. Magic starts here.
    ------------------
    -- TicToc Stuff
    ------------------
    -- Check to see if TicToc running
    tell application "System Events"
        set tictocRunning to (count of (every process whose name is "Tictoc")) > 0
    end tell

    if tictocRunning then
        tell application "Tictoc"
            set ttTaskList to name of every task
        end tell
    else
        tell application "Tictoc"
            activate
            set ttTaskList to name of every task
        end tell
    end if

    -- Get list of Tasks currently in TicToc
    -- This is needed because TitToc still doesn't allow creation of new tasks via AppleScript
    tell application "Tictoc"
        set ttTaskList to name of every task
    end tell


    tell application "TaskPaper"
        if the entry type of selected entry is not task type then
            my displayMessage("Errors", "Error", "The selected entry is not a task.")
        else
            tell selected entry
                set tagList to name of tags
                if tagList contains trackTag then
                    set trackEvent to value of tag named trackTag
                    if ttTaskList contains trackEvent then
                        if tagList does not contain "tracking" then
                            make tag with properties {name:"tracking"}
                            tell application "Tictoc"
                                if (start task trackEvent) then
                                    my displayMessage("Tracking Time", "Tracking Time", "Successfully started time tracking for this task.")
                                else
                                    my displayMessage("Errors", "Error", "There was a problem and starting time tracking for this task.")
                                end if

                            end tell
                        else
                            delete tag named "tracking"
                            tell application "Tictoc"
                                if (stop task trackEvent) then
                                    my displayMessage("Tracking Time", "Tracking Time", "Successfully stoped time tracking for this task.")
                                else
                                    my displayMessage("Errors", "Error", "There was a problem stopping time tracking for this task.")
                                end if
                            end tell
                        end if
                    else
                        my displayMessage("Errors", "Error", "There is no task '" & trackEvent & "' in TicToc. Please create it first")
                    end if
                else
                    my displayMessage("Errors", "Error", "This task doesn't appear to have a tag associated with time tracking.")
                end if
            end tell
        end if
    end tell

    to displayMessage(msgName, msgTitle, msgText)
        -- Check to see if it's running
        tell application "System Events"
            set growlRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
        end tell

        -- Register Growl
        if growlRunning then
            tell application id "com.Growl.GrowlHelperApp"
                -- Make a list of all the notification types 
                -- that this script will ever send:
                set the allNotificationsList to ¬
                    {"Tracking Time", "Errors"}

                -- Make a list of the notifications 
                -- that will be enabled by default.      
                -- Those not enabled by default can be enabled later 
                -- in the 'Applications' tab of the Growl preferences.
                set the enabledNotificationsList to ¬
                    {"Tracking Time", "Errors"}

                -- Register our script with growl.
                -- You can optionally (as here) set a default icon 
                -- for this script's notifications.
                register as application ¬
                    "TaskPaper Timetracking" all notifications allNotificationsList ¬
                    default notifications enabledNotificationsList ¬
                    icon of application "TaskPaper"
            end tell
        end if

        -- Display the Message
        if growlRunning then
            tell application id "com.Growl.GrowlHelperApp"
                notify with name ¬
                    msgName title ¬
                    msgTitle description ¬
                    msgText application name ¬
                    "TaskPaper Timetracking"
            end tell
        else
            display dialog msgText
        end if

    end displayMessage

    --  This program is free software: you can redistribute it and/or modify
    --  it under the terms of the GNU General Public License as published by
    --  the Free Software Foundation, either version 3 of the License, or
    --  (at your option) any later version.
    --
    --  This program is distributed in the hope that it will be useful,
    --  but WITHOUT ANY WARRANTY; without even the implied warranty of
    --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    --  GNU General Public License for more details.
    --
    --  You should have received a copy of the GNU General Public License
    --  along with this program.  If not, see <http://www.gnu.org/licenses/>.