Skip to content

Instantly share code, notes, and snippets.

@mikedamage
Created November 17, 2010 19:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mikedamage/703898 to your computer and use it in GitHub Desktop.
Save mikedamage/703898 to your computer and use it in GitHub Desktop.
Fluid userscript for Harvest Timer app. Pops a Growl notification every so often to remind me to track my hours if no timer is currently running.
// ==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 :
@lgedeon
Copy link

lgedeon commented Jan 28, 2012

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.

@mikedamage
Copy link
Author

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/

@mikedamage
Copy link
Author

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.

@lgedeon
Copy link

lgedeon commented Jan 28, 2012 via email

@mikedamage
Copy link
Author

mikedamage commented Jan 28, 2012 via email

@blentz100
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment