Skip to content

Instantly share code, notes, and snippets.

@abachman
Forked from ngauthier/pom.rb
Created June 18, 2010 16:55
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 abachman/443897 to your computer and use it in GitHub Desktop.
Save abachman/443897 to your computer and use it in GitHub Desktop.
pomodoro timer
#!/usr/bin/env ruby
def notify(msg)
puts "[#{ Time.now.strftime "%H:%M:%S" }]: #{msg}"
`notify-send -i /home/adam/Documents/images/icons/pomodoro.png "Pomodoro" "#{msg}"`
end
POMODORO = ARGV.size > 0 ? ARGV[0].to_i : 25
REST = ARGV.size > 1 ? ARGV[1].to_i : 5
if ARGV.length > 2
puts "Usage: pomodoro [work time] [rest time]"
exit(1)
end
notify "time to flow. work #{ POMODORO }, rest #{ REST }."
1.upto(POMODORO) do |minute|
sleep 60
puts "#{minute}/#{POMODORO}"
if minute == (POMODORO-5)
notify "Five minutes left!"
end
if minute == (POMODORO-1)
notify "One minute left!"
end
end
`rhythmbox-client --pause`
`gnome-screensaver-command -a`
sleep REST * 60
`gnome-screensaver-command -d`
notify "Welcome Back"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment