From 32fb349db7af96031604310778eb0015b56923b7 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 29 Jan 2021 01:35:05 +0100 Subject: [PATCH] Able to ignore low idle time (in case I'm not alone and write on my computer) --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 3ececa2..7447769 100644 --- a/main.go +++ b/main.go @@ -159,6 +159,7 @@ func loadFile(path string) (s beep.StreamSeekCloser, format beep.Format, err err func main() { var weatherTime = flag.Duration("weather", -1, "Speak weather?") var noshuffle = flag.Bool("noshuffle", false, "Don't shuffle music order") + var ignoreidle = flag.Bool("ignoreidle", false, "Don't stop the reveil on idle detection change") var sr = flag.Int("samplerate", 44100, "Samplerate for unifying output stream") var claironTime = flag.Duration("clairon", -1, "Time before running the wake up clairon song") flag.DurationVar(&MaxRunTime, "maxruntime", MaxRunTime, "Maximum duration before auto exit") @@ -278,8 +279,12 @@ loop: volume.Volume = -2 - math.Log(5/float64(ntick))/3 } - if xPrintIdle() < idle { - break loop + if ignoreidle == nil || !*ignoreidle { + if idle < 60000 { + idle = xPrintIdle() + } else if xPrintIdle() < idle { + break loop + } } case <-interrupt: break loop