Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added growl support

adam wróbel <amw> is pretty awesome, and came up with this idea,
making his own fork for the app. (he also added a pause button to
his fork. check it out.) i've ripped off andy hedges' method of
sending growl notifications:

<http://andrew.hedges.name/blog/2009/03/14/sending-growl-notifications-from-dashboard-widgets>

nice.
  • Loading branch information...
commit 7ded00f9be877aa4c92d1ba7b03db94396ef95bc 1 parent 5e97def
@redoPop authored
View
10 1025/1025.html
@@ -1,9 +1,9 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!--
+ because dashboard widgets often contain nonstandard elements,
+ i'm not going to pretend compliance by sticking a doctype here.
+-->
+<html>
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8 "/>
<title>(10+2)5</title>
<style type="text/css">@import "1025.css";</style>
View
25 1025/1025.js
@@ -1,5 +1,4 @@
-intervalId = 0;
-on = 0;
+intervalId = 0, on = 0;
function count() {
seconds++;
@@ -25,6 +24,18 @@ function countdown() {
state(text);
}
+function growl(title, body) {
+ setTimeout(function() {
+ widget.system('growl-enabled.sh', function (obj) {
+ var cmd;
+ if (+obj.outputString > 0) {
+ cmd = '/usr/bin/osascript growl-notify.scpt "'+title+'" "(10+2)5" "Dashboard" "'+title+'" "'+body+'"';
+ widget.system(cmd, function (obj) {});
+ }
+ });
+ }, 1);
+}
+
function init() {
if (window.widget) createGenericButton(document.getElementById('start'), '(10+2)5', punch);
}
@@ -52,15 +63,18 @@ function startTimer() {
}
function startWork() {
- var text = 'Start. ';
seconds = 0;
working = 1;
+
+ var notifyHour = 0;
if (cycles>0 && cycles%5==0) {
hours++;
- text += ' Hour ' + (hours+1);
+ var notifyHour = (hours+1);
}
cycles++;
- say(text);
+
+ say('Start. ' + (notifyHour>0 ? 'Hour '+notifyHour : ''));
+ growl('Start Work', 'Start working.' + (notifyHour>0 ? "\rHours: "+notifyHour : ''));
}
function state(text) {
@@ -76,6 +90,7 @@ function stopTimer() {
function stopWork() {
working = 0;
say('Stop');
+ growl('Stop Work', 'Stop working.');
}
function toggle() {
View
2  1025/Info.plist
@@ -11,7 +11,7 @@
<key>CFBundleIdentifier</key>
<string>com.jdbartlett.widget.1025</string>
<key>CFBundleVersion</key>
- <string>1.0.1</string>
+ <string>1.0.2</string>
<key>CloseBoxInsetX</key>
<integer>10</integer>
<key>CloseBoxInsetY</key>
View
6 1025/growl-enabled.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+osascript<<END
+tell application "System Events"
+ return count of (every process whose name is "GrowlHelperApp")
+end tell
+END
View
BIN  1025/growl-notify.scpt
Binary file not shown
View
4 README
@@ -9,8 +9,10 @@ button to skip to break. To stop the clock completely, punch the button
during break (i.e., twice if it thinks you’re working).
Uses OS X's speech synthesizer to make inconspicuous announcements, so check
-your volume!
+your volume! As of 1.0.2, wee Growl notifications are sent out (thanks, Adam
+Wróbel <amw>, for the idea!)
+--
Mac OS X 10.4 Tiger is required. If you’re using Safari, click the download
link. When the widget download is complete, show Dashboard, click the Plus
Please sign in to comment.
Something went wrong with that request. Please try again.