Skip to content

Instantly share code, notes, and snippets.

@fnichol
Forked from xiplias/esca.rb
Created November 21, 2011 16:41
Show Gist options
  • Save fnichol/1383177 to your computer and use it in GitHub Desktop.
Save fnichol/1383177 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 dependency campy:

git clone git://gist.github.com/1383177.git ~/Dropbox/esca
sudo gem install campy --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 'campy'
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 = MultiJson.decode(IO.read(json_file))[account] or exit
room = Campy::Room.new(:account => data['domain'], :room => data['room'],
:token => data['token'])
end_time = Time.now + (60*duration.to_i)
formated_end_time = end_time.getutc.strftime("%H:%M:%S-0000")
case action
when "start"
msg = "Started '#{name}' - " +
"Ends in #{duration} minutes at #{formated_end_time}"
when "reset"
msg = "Reset '#{name}'"
when "stop"
msg = "Stopped '#{name}'"
end
room.speak "Pomodoro: #{msg}"
## 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