Created
June 14, 2014 12:17
-
-
Save ascendbruce/c4a823b3202d7ed6f80e to your computer and use it in GitHub Desktop.
Terminal & mac say stopwatch for interval training
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
class Notifier | |
def initialize(voice) | |
@voice | |
end | |
def sprint | |
say "sprint" | |
puts %( | |
###### ######## ######## #### ## ## ######## | |
## ## ## ## ## ## ## ### ## ## | |
## ## ## ## ## ## #### ## ## | |
###### ######## ######## ## ## ## ## ## | |
## ## ## ## ## ## #### ## | |
## ## ## ## ## ## ## ### ## | |
###### ## ## ## #### ## ## ## | |
), "\n"*5 | |
end | |
def relax | |
say "relax" | |
puts %( | |
######## ######## ## ### ## ## | |
## ## ## ## ## ## ## ## | |
## ## ## ## ## ## ## ## | |
######## ###### ## ## ## ### | |
## ## ## ## ######### ## ## | |
## ## ## ## ## ## ## ## | |
## ## ######## ######## ## ## ## ## | |
), "\n"*5 | |
end | |
private | |
def say(message) | |
if @voice && !@voice.empty? | |
system("say -v #{@voice} '#{message}' &") | |
else | |
system("say '#{message}' &") | |
end | |
end | |
end | |
# === configs === | |
voice = "" # leave blank or nil to use the default | |
sprint_duration = 30 # in seconds | |
relax_duration = 4 * 60 | |
# =============== | |
notifier = Notifier.new(voice) | |
begin | |
while true | |
notifier.relax | |
sleep relax_duration | |
notifier.sprint | |
sleep sprint_duration | |
end | |
rescue Interrupt => e | |
puts "", "bye bye" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment