Created
November 17, 2010 19:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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 : |
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.
Wow, I wish I had seen hayfever before I got the paid version of fluid, but
I think I will use fluid for other things anyway.
You should let harvest now about hayfever too so they can add it to their
apps page.
I will take a look at adding the icon changer, any tips would be
appreciated.
…---
Luke Gedeon
http://luke.gedeon.name
On Sat, Jan 28, 2012 at 1:35 PM, Mike Green < ***@***.*** > wrote:
P.S. If you use Google Chrome, check out the Harvest extension I wrote for
it. It's called [Hayfever](http://mikedamage.github.com/hayfever-chrome).
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.
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/703898
Harvest does know about it, but I think they'll only promote apps that they themselves made. They helped get the word out on Twitter back when I released it though.
So Chrome extensions can use Canvas elements or PNG images as their icons. Here's the relevant part of the Chrome extension API: http://code.google.com/chrome/extensions/browserAction.html#method-setIcon
I'd suggest reading all their docs and not just the relevant part. Chrome can do some amazing things with extensions.
##
Mike Green
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
…On Saturday, January 28, 2012 at 1:54 PM, lgedeon wrote:
Wow, I wish I had seen hayfever before I got the paid version of fluid, but
I think I will use fluid for other things anyway.
You should let harvest now about hayfever too so they can add it to their
apps page.
I will take a look at adding the icon changer, any tips would be
appreciated.
---
Luke Gedeon
http://luke.gedeon.name
On Sat, Jan 28, 2012 at 1:35 PM, Mike Green <
***@***.*** ***@***.***)
> wrote:
>
> P.S. If you use Google Chrome, check out the Harvest extension I wrote for
> it. It's called [Hayfever](http://mikedamage.github.com/hayfever-chrome).
>
> 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.
> ---
>
> Reply to this email directly or view it on GitHub:
> https://gist.github.com/703898
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/703898
@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
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/