-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
51 lines (40 loc) · 785 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"os"
"strconv"
"time"
"github.com/gumieri/sway-session/session"
"github.com/gumieri/typist"
)
var t = typist.New(&typist.Config{})
func main() {
if len(os.Args) <= 1 {
return
}
switch os.Args[1] {
case "save":
s, err := session.New()
t.Must(err)
t.Must(s.Save())
case "save-loop":
durationInterval := time.Duration(60)
if len(os.Args) >= 3 {
interval, err := strconv.Atoi(os.Args[2])
t.Must(err)
durationInterval = time.Duration(interval)
}
for {
s, err := session.New()
t.Must(err)
time.Sleep(durationInterval * time.Second)
t.Must(s.Save())
session.CleanUp()
}
case "restore":
s, err := session.LoadNewest()
t.Must(err)
t.Must(s.Restore())
case "clean-up":
t.Must(session.CleanUp())
}
}