Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a free or cheap little app called Desktop Task Timer LE that I've been using to track my time as I work on various projects. I'd like to have it pop up as the foreground app every 15 minutes to prevent me from forgetting to stop/change the timer after I've moved on to a different task. I know I can have the app launch using a script in Automator or AppleScript, but I don't know how to have that script fire off every 15 minutes. I've read about using Launchd and iCal, but I'm still not sure how to do it. (Actually, iCal is probably simple, but I'd like to avoid using it for this.) Any ideas?

Also, a further feature would be to have it pop up after 5 (or x) minutes of inactivity on the computer. Not sure if this would work for my needs, but I'd like to test it if possible.

share|improve this question

migrated from stackoverflow.com Oct 21 '11 at 19:00

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 3 down vote accepted

~/Library/LaunchAgents/com.stackoverflow.open.desktop.task.timer.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.stackoverflow.open.desktop.task.timer</string>
    <key>ProgramArguments</key>
    <array>
        <string>open</string>
        <string>-a</string>
        <string>Desktop Task Timer LE</string>
    </array>
    <key>StartInterval</key>
    <integer>900</integer> <!-- every 900 seconds -->
    <key>RunAtLoad</key> <!--run on the 0th second-->
    <true/>
</dict>
</plist>

launchctl load ~/Library/LaunchAgents/com.stackoverflow.open.desktop.task.timer.plist or log out and back in.

crontab -e

*/15 * * * * open -a "Desktop Task Timer LE"
  • You can use a different editor like EDITOR=nano crontab -e
  • crontab -l lists currently scheduled tasks
  • crontab /path/to/file updates the table from an external file
share|improve this answer
    
Thanks a lot; this seemed to work. –  johnnyb10 Oct 20 '11 at 19:49

I see Lri's answer and you have chosen it as your correct answer. I wanted to show you a different approach that would also handle the second "feature" you requested. This method uses launchd too but that runs an applescript. Here's the applescript. Notice that I checked it using TextEdit so just change that to your application name.

property lastRunDate : missing value

set currentDate to current date
if lastRunDate is missing value then set lastRunDate to currentDate
set idleTime to (do shell script "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print $NF/1000000000; exit}'") as number

-- check if the computer has been idle for 5 minutes or if 15 minutes has passed
if idleTime is greater than or equal to (5 * 60) or (currentDate - lastRunDate) is greater than or equal to (15 * 60) then
    tell application "TextEdit" to activate
    set lastRunDate to currentDate
end if

Here's the launchd plist. Notice this runs every 5 minutes and the applescript does the checking for your 5 minute criteria or your 15 minute criteria. You can see from this that I called the applescript "FiveMinuteRunner.scpt" and placed it on my desktop. Good luck :)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>StartInterval</key>
    <integer>300</integer>
    <key>ProgramArguments</key>
    <array>
        <string>osascript</string>
        <string>/Users/hmcshane/Desktop/FiveMinuteRunner.scpt</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>Label</key>
    <string>com.HAMSoftEnginnering.FiveMinuteRunner</string>
</dict>
</plist>
share|improve this answer

Why dont you use Growl for notification, it's better solution dont you thing?
You can even add sounds to it.
http://growl.info/

enter image description here

share|improve this answer
    
I think the application has to support Growl, doesn't it? I don't think Desktop Task Timer does. –  johnnyb10 Oct 20 '11 at 15:27
    
Aww man I thought you where the developer of the app :/ my bad. –  JeremySpouken Oct 20 '11 at 15:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.