diff --git a/Makefile b/Makefile index 6047ceb..f3670c3 100644 --- a/Makefile +++ b/Makefile @@ -14,5 +14,8 @@ LDFLAGS=-ldflags "-w -s -X cmd.Version=${VERSION} -X cmd.Build=${BUILD}" breaktime: go build ${LDFLAGS} -o build/${BINARY} +install: + mv build/${BINARY} ${GOPATH}/bin + clean: rm build/* diff --git a/cmd/i3.go b/cmd/i3.go index d4bccc5..fae86c0 100644 --- a/cmd/i3.go +++ b/cmd/i3.go @@ -1,6 +1,5 @@ /* Copyright © 2023 Brian Buller - */ package cmd @@ -40,11 +39,15 @@ var i3Cmd = &cobra.Command{ lastBreak := viper.GetTime("lastbreak") pomo := viper.GetDuration("pomodoro") warnPct := viper.GetFloat64("warnpct") //0.75 - warn := float64(pomo.Seconds() * warnPct) - elapsed := time.Since(lastBreak).Seconds() + warn := int(pomo.Seconds() * warnPct) + elapsed := int(time.Since(lastBreak).Seconds()) rem := time.Until(lastBreak.Add(pomo)).Round(time.Duration(time.Second)) - if elapsed > pomo.Seconds() { - fmt.Print("{\"icon\":\"time\",\"state\":\"Critical\", \"text\": \"BREAK!\"}") + if elapsed > int(pomo.Seconds()) { + state := "Critical" + if elapsed%2 == 1 { + state = "Warning" + } + fmt.Printf("{\"icon\":\"time\",\"state\":\"%s\", \"text\": \"BREAK!\"}", state) } else if elapsed > warn { fmt.Printf("{\"icon\":\"time\",\"state\":\"Warning\", \"text\": \"%s\"}", rem) } else {