Last active
August 29, 2015 14:01
-
-
Save sebastian/9082904e6ea6f64d15c8 to your computer and use it in GitHub Desktop.
Pomodoro update script for sqwiggle
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'sqwiggle-ruby' | |
# We default to pomodori of 25 minute length. | |
# If the timer is started too late, you can | |
# start shorter pomodori by supplying the | |
# time as the first argument. | |
minutes = ARGV.size == 0 ? 25 : ARGV[0].to_i | |
if minutes < 0 then | |
puts "You need a positive pomodori minute length" | |
exit 1 | |
end | |
puts "Starting a #{minutes} minute pomodoro" | |
Sqwiggle.token = "<Your-Token>" # "standard" token from https://www.sqwiggle.com/company/clients | |
@me = Sqwiggle::User.find(:me) | |
def set_status p={} | |
@me.update(status: p[:status] || :busy, message: p[:message] || "") | |
end | |
minutes.downto(1) do |minutesRemaining| | |
startTime = Time.now | |
set_status message: "Pomodoro (#{minutesRemaining} min left)" | |
sleep(60 - (Time.now - startTime)) | |
end | |
set_status status: :available | |
puts "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment