Make 'Break' more annoying
This commit is contained in:
parent
004ca7ab5b
commit
1ef19ca9c7
3
Makefile
3
Makefile
@ -14,5 +14,8 @@ LDFLAGS=-ldflags "-w -s -X cmd.Version=${VERSION} -X cmd.Build=${BUILD}"
|
|||||||
breaktime:
|
breaktime:
|
||||||
go build ${LDFLAGS} -o build/${BINARY}
|
go build ${LDFLAGS} -o build/${BINARY}
|
||||||
|
|
||||||
|
install:
|
||||||
|
mv build/${BINARY} ${GOPATH}/bin
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm build/*
|
rm build/*
|
||||||
|
13
cmd/i3.go
13
cmd/i3.go
@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright © 2023 Brian Buller <brian@bullercodeworks.com>
|
Copyright © 2023 Brian Buller <brian@bullercodeworks.com>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
@ -40,11 +39,15 @@ var i3Cmd = &cobra.Command{
|
|||||||
lastBreak := viper.GetTime("lastbreak")
|
lastBreak := viper.GetTime("lastbreak")
|
||||||
pomo := viper.GetDuration("pomodoro")
|
pomo := viper.GetDuration("pomodoro")
|
||||||
warnPct := viper.GetFloat64("warnpct") //0.75
|
warnPct := viper.GetFloat64("warnpct") //0.75
|
||||||
warn := float64(pomo.Seconds() * warnPct)
|
warn := int(pomo.Seconds() * warnPct)
|
||||||
elapsed := time.Since(lastBreak).Seconds()
|
elapsed := int(time.Since(lastBreak).Seconds())
|
||||||
rem := time.Until(lastBreak.Add(pomo)).Round(time.Duration(time.Second))
|
rem := time.Until(lastBreak.Add(pomo)).Round(time.Duration(time.Second))
|
||||||
if elapsed > pomo.Seconds() {
|
if elapsed > int(pomo.Seconds()) {
|
||||||
fmt.Print("{\"icon\":\"time\",\"state\":\"Critical\", \"text\": \"BREAK!\"}")
|
state := "Critical"
|
||||||
|
if elapsed%2 == 1 {
|
||||||
|
state = "Warning"
|
||||||
|
}
|
||||||
|
fmt.Printf("{\"icon\":\"time\",\"state\":\"%s\", \"text\": \"BREAK!\"}", state)
|
||||||
} else if elapsed > warn {
|
} else if elapsed > warn {
|
||||||
fmt.Printf("{\"icon\":\"time\",\"state\":\"Warning\", \"text\": \"%s\"}", rem)
|
fmt.Printf("{\"icon\":\"time\",\"state\":\"Warning\", \"text\": \"%s\"}", rem)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user