Make 'Break' more annoying

This commit is contained in:
Brian Buller 2023-11-28 08:13:06 -06:00
parent 004ca7ab5b
commit 1ef19ca9c7
2 changed files with 11 additions and 5 deletions

View File

@ -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/*

View File

@ -1,6 +1,5 @@
/*
Copyright © 2023 Brian Buller <brian@bullercodeworks.com>
*/
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 {