add bell sound! via sox

This commit is contained in:
Lee 2023-08-23 20:50:10 -04:00
parent 46c8572578
commit ab11bafb45
1 changed files with 31 additions and 3 deletions

34
pom
View File

@ -1,9 +1,10 @@
#! /usr/bin/env lua
-- requires sox to play bell sound
local alt_getopt = require 'alt_getopt'
local term = require 'term'
local times = 1
local times = 4
local nb = false -- "no break"
local long_opts = {
help = "h",
@ -19,6 +20,7 @@ local tic = 1
local endTime = startTime+10 --10 seconds
local pomodoro = 25*60
local breaktime = 5*60
local longbreak = 20*60
local i
@ -76,6 +78,13 @@ function _process_args()
end
end
function bell()
--Play a bell sound if we have sox installed, via the shell
os.execute("play -n synth 2 sin 960 fade l 0 1 0.9")
end
function toMin(seconds)
--rounding up to the nearest minute
return math.ceil(seconds/60)
@ -115,6 +124,7 @@ function _pomodoro()
end
function _break()
print("Starting 5 minute break")
i = breaktime
@ -128,6 +138,20 @@ function _break()
end
function _longbreak()
print("Starting 20 minute break")
i = longbreak
repeat
wait()
term.cursor.group(1)
until i<= 0
end
----------------- start ----------------
_process_args()
@ -135,10 +159,14 @@ _process_args()
for poms = 1,times
do
_pomodoro()
bell()
if not nb then
if poms==4 and not nb then
_longbreak()
elseif poms~=4 and not nb then
_break()
end
bell()
end
print(times .. " pomodoros completed")
print(times .. " pomodoros completed.")