add custom message to timer
parent
180013f709
commit
1a8fff92ae
4
main.go
4
main.go
|
|
@ -12,6 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var notified = false
|
var notified = false
|
||||||
|
var alertMessage string
|
||||||
|
|
||||||
var originalStart = time.Now()
|
var originalStart = time.Now()
|
||||||
|
|
||||||
|
|
@ -28,6 +29,7 @@ func main() {
|
||||||
flag.BoolVar(&invert, "stopwatch", false, "Use as a stopwatch")
|
flag.BoolVar(&invert, "stopwatch", false, "Use as a stopwatch")
|
||||||
flag.StringVar(&duration, "duration", "30m", "How long the timer should be")
|
flag.StringVar(&duration, "duration", "30m", "How long the timer should be")
|
||||||
flag.StringVar(&offset, "offset", "0m", "How much time the initial time should skip")
|
flag.StringVar(&offset, "offset", "0m", "How much time the initial time should skip")
|
||||||
|
flag.StringVar(&alertMessage, "msg", "Timer up", "Message to display on timer expiration")
|
||||||
flag.StringVar(&interval, "interval", "500ms", "Interval duration")
|
flag.StringVar(&interval, "interval", "500ms", "Interval duration")
|
||||||
flag.BoolVar(&eta, "eta", false, "Whether to display the ending time")
|
flag.BoolVar(&eta, "eta", false, "Whether to display the ending time")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
@ -179,7 +181,7 @@ func printTime(pRemains *time.Duration, target time.Duration, delim *rune, rever
|
||||||
func alertTime(pRemains *time.Duration, target time.Duration, reverse, repeat bool) {
|
func alertTime(pRemains *time.Duration, target time.Duration, reverse, repeat bool) {
|
||||||
if !notified {
|
if !notified {
|
||||||
notified = true
|
notified = true
|
||||||
_, err := mack.Alert(fmt.Sprintf("Timer for %s done", target.String()))
|
_, err := mack.Alert(fmt.Sprintf("%s\nTimer for %s done", alertMessage, target.String()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue