-
-
Save mikedamage/703898 to your computer and use it in GitHub Desktop.
// ==UserScript== | |
// @name Harvest Timer Growl Reminder | |
// @namespace http://harvestapp.com | |
// @description Displays Growl notifications at a user defined interval, reminding you to track your time. | |
// @include * | |
// @author Mike Green | |
// @version 0.1.1 | |
// ==/UserScript== | |
(function () { | |
if (window.fluid) { | |
var growlInterval = 45000; // (in milliseconds) | |
window.growlReminder = window.setInterval(growlAtUser, growlInterval); | |
// TODO: Create a form to set the notification interval | |
// Create a link to start/stop the notifications | |
var pauseLink = document.createElement('a'); | |
pauseLink.href = "#"; | |
pauseLink.innerHTML = "Stop Growl Reminders"; | |
pauseLink.onclick = function(e) { | |
if (window.growlReminder) { | |
window.clearInterval(window.growlReminder); | |
window.growlReminder = null; | |
e.target.innerHTML = "Start Growl Reminders"; | |
} else { | |
window.growlReminder = window.setInterval(growlAtUser, growlInterval); | |
e.target.innerHTML = "Stop Growl Reminders"; | |
} | |
return false; | |
}; | |
document.getElementById('mainbody').appendChild(pauseLink); | |
} | |
})(); | |
function timerStopped() { | |
try { | |
return (window.timesheet.daily_stopwatch_timer_running_id == ""); | |
} catch(e) { | |
return true; | |
} | |
} | |
function growlAtUser() { | |
if (timerStopped()) { | |
window.fluid.showGrowlNotification({ | |
title: "Track your time!" | |
, description: "Harvest wants to know what you're working on." | |
, priority: 1 | |
}); | |
} | |
} | |
// vim: set ts=2 sw=2 smartindent : |
You might be able to do something like that with the new paid version of Fluid's developer API, but I'm pretty sure that's beyond the open source version's capabilities. It's been a while since I wrote this, so I don't know that for sure tho.
As far as resources, I used Fluid's API page as my main reference when I wrote this. That page has change since the author re-released the app tho. http://fluidapp.com/developer/
P.S. If you use Google Chrome, check out the Harvest extension I wrote for it. It's called Hayfever.
One thing I haven't added yet is an icon that changes depending on timer status, but I could definitely point you in the right direction if you decided to fork it.
@Igdeon - Did you ever figure out a way to put an icon in the menubar? I'm looking for the same thing...
Hi Mike,
I am trying to figure out how to do something similar to this, but instead of growl, I want to put an icon in the menubar and possibly the time showing on the current timer. So I have one icon if the timer is on and another if it is off.
If you have any suggestions to point me in the right direction, or suggestions for documentation, I would appreciate it.
Hi Mike,
I am trying to figure out how to do something similar to this, but instead of growl, I want to put an icon in the menubar and possibly the time showing on the current timer. So I have one icon if the timer is on and another if it is off.
If you have any suggestions to point me in the right direction, or suggestions for documentation, I would appreciate it.