|
|
@ -8,6 +8,7 @@ import (
|
|
8
|
8
|
"encoding/json"
|
|
9
|
9
|
"fmt"
|
|
10
|
10
|
"os"
|
|
|
11
|
"os/exec"
|
|
11
|
12
|
"path"
|
|
12
|
13
|
"time"
|
|
13
|
14
|
)
|
|
|
@ -40,9 +41,11 @@ func main() {
|
|
40
|
41
|
dur := now.Sub(*day.BreakStart)
|
|
41
|
42
|
day.Break += dur
|
|
42
|
43
|
day.BreakStart = nil
|
|
|
44
|
notifyCompletion(fmt.Sprintf("took a %s break", dur), 0)
|
|
43
|
45
|
fmt.Fprintf(os.Stderr, "took a %s break\n", dur)
|
|
44
|
46
|
} else {
|
|
45
|
47
|
day.BreakStart = &now
|
|
|
48
|
notifyCompletion("taking a break", 10*time.Hour)
|
|
46
|
49
|
}
|
|
47
|
50
|
writeDay(dayFile, day)
|
|
48
|
51
|
}
|
|
|
@ -53,6 +56,7 @@ func main() {
|
|
53
|
56
|
fmt.Fprintln(os.Stderr, err)
|
|
54
|
57
|
os.Exit(1)
|
|
55
|
58
|
}
|
|
|
59
|
notifyCompletion(fmt.Sprintf("took a %s break", dur), 0)
|
|
56
|
60
|
fmt.Fprintf(os.Stderr, "took a %s break\n", dur)
|
|
57
|
61
|
day.Break += dur
|
|
58
|
62
|
writeDay(dayFile, day)
|
|
|
@ -98,3 +102,13 @@ func writeDay(path string, day Day) {
|
|
98
|
102
|
os.Exit(1)
|
|
99
|
103
|
}
|
|
100
|
104
|
}
|
|
|
105
|
|
|
|
106
|
func notifyCompletion(msg string, dur time.Duration) {
|
|
|
107
|
args := make([]string, 0, 1)
|
|
|
108
|
if dur != 0 {
|
|
|
109
|
args = append(args, "--expire-time", fmt.Sprintf("%d", int(dur.Seconds()*1000)))
|
|
|
110
|
}
|
|
|
111
|
args = append(args, msg)
|
|
|
112
|
notifyCmd := exec.Command("notify-send", args...)
|
|
|
113
|
notifyCmd.Run()
|
|
|
114
|
}
|