-
-
Save abachman/443897 to your computer and use it in GitHub Desktop.
pomodoro timer
This file contains hidden or 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 | |
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