Skip to content

Instantly share code, notes, and snippets.

@mikedamage
Created November 17, 2010 19:29
Show Gist options
  • 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 :
@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