Skip to content

Instantly share code, notes, and snippets.

@glennr
Forked from fnichol/README.md
Created December 8, 2011 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennr/1446891 to your computer and use it in GitHub Desktop.
Save glennr/1446891 to your computer and use it in GitHub Desktop.
Campfire script for Pomodoro

Description

Simple Campfire notifier for the Pomodoro app, based off xiplias's gist.

The script reads a JSON file to match a leading pomodoro tag with a Campfire account. In the example file there is a campfire account with tag called "wco". Any pomodoros starting with "wco-", "wco_", "wco," will use the "wco" campfire account. If no campfire account exists with the leading tag, nothing will be broadcast.

Installation

First, clone down the repo and install the gem dependencies (tinder and json):

git clone git://gist.github.com/1383177.git ~/Dropbox/esca
sudo gem install json tinder --no-ri --no-rdoc

On the Mac, the system installed Ruby will be used (hence the sudo).

Now modify campfire.json with your campfire account (or accounts). Finally, open Preferences in Pomodoro, go to the Scripts tab, and paste the contents of start.scpt in the Start textarea (and stop.scpt Stop).

{
"wco": {
"token": "token_api_key_here",
"domain": "widgetco",
"room": "Dev room"
}
}
require 'rubygems'
require 'json'
require 'tinder'
action, name, duration, *therest = ARGV
account = name.split(/(-|,|_)/).first
json_file = File.join(File.dirname(__FILE__), "campfire.json")
# skip status update if no campfire account is "tagged"
data = JSON.parse(IO.read(json_file))[account] or exit
campfire = Tinder::Campfire.new data['domain'], :token => data['token']
room = campfire.find_room_by_name data['room']
end_time = Time.now + (60*duration.to_i)
formated_end_time = end_time.strftime("%H:%M")
case action
when "start"
speak = "Started '#{name}' - Ends in #{duration} minutes at #{formated_end_time}"
when "reset"
speak = "Reset '#{name}'"
when "stop"
speak = "Stopped '#{name}'"
end
room.speak "Pomodoro: #{speak}"
## Put into the Reset field in the Scripts tab in Pomodoro
do shell script "ruby ~/Dropbox/esca/esca.rb reset \"$pomodoroName\""
## Put into the Start field in the Scripts tab in Pomodoro
do shell script "ruby ~/Dropbox/esca/esca.rb start \"$pomodoroName\" $duration"
## Put into the Stop field in the Scripts tab in Pomodoro
do shell script "ruby ~/Dropbox/esca/esca.rb stop \"$pomodoroName\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment