-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmain.go
89 lines (66 loc) · 1.7 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"fmt"
"os/exec"
"github.com/asaskevich/EventBus"
_ "embed"
"github.com/olup/kobowriter/screener"
"github.com/olup/kobowriter/utils"
"github.com/olup/kobowriter/views"
)
var saveLocation = "/mnt/onboard/.adds/kobowriter"
var filename = "autosave.txt"
func main() {
fmt.Println("Program started")
// kill all nickel related stuff. Will need a reboot to find back the usual
fmt.Println("Killing XCSoar programs ...")
exec.Command("killall", "-s", "SIGKILL", "KoboMenu").Run()
// rotate screen
fmt.Println("Rotate screen ...")
exec.Command(`fbdepth`, `--rota`, `2`).Run()
// initialise fbink
fmt.Println("Init FBInk ...")
screen := screener.InitScreen()
defer screen.Clean()
bus := EventBus.New()
c := make(chan bool)
defer close(c)
bus.SubscribeAsync("REQUIRE_KEYBOARD", func() {
findKeyboard(screen, bus)
}, false)
bus.SubscribeAsync("QUIT", func() {
screen.PrintAlert("Good Bye !", 500)
// quitting
c <- true
return
}, false)
var unmount func()
bus.SubscribeAsync("ROUTING", func(routeName string) {
if unmount != nil {
unmount()
}
switch routeName {
case "document":
config := utils.LoadConfig(saveLocation)
unmount = views.Document(screen, bus, config.LastOpenedDocument)
case "menu":
unmount = views.MainMenu(screen, bus, saveLocation)
case "file-menu":
unmount = views.FileMenu(screen, bus, saveLocation)
case "settings-menu":
unmount = views.SettingsMenu(screen, bus, saveLocation)
case "qr":
unmount = views.Qr(screen, bus, saveLocation)
default:
unmount = views.Document(screen, bus, "")
}
}, false)
// init
bus.Publish("REQUIRE_KEYBOARD")
for quit := range c {
if quit {
break
}
}
println("yo")
}