forked from creamlike1024/EasyLPAC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
67 lines (57 loc) · 1.35 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
package main
import (
"fmt"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/dialog"
"os"
"path/filepath"
)
const Version = "development"
const EUICCDataVersion = "unknown"
var App fyne.App
func init() {
App = app.New()
App.Settings().SetTheme(&MyTheme{})
if err := LoadConfig(); err != nil {
panic(err)
}
if _, err := os.Stat(ConfigInstance.LogDir); os.IsNotExist(err) {
err := os.Mkdir(ConfigInstance.LogDir, 0755)
if err != nil {
panic(err)
}
}
}
func main() {
var err error
ConfigInstance.LogFile, err = os.Create(filepath.Join(ConfigInstance.LogDir, ConfigInstance.LogFilename))
if err != nil {
panic(err)
}
defer ConfigInstance.LogFile.Close()
InitWidgets()
go UpdateStatusBarListener()
go LockButtonListener()
WMain = InitMainWindow()
_, err = os.Stat(filepath.Join(ConfigInstance.LpacDir, ConfigInstance.EXEName))
if err != nil {
d := dialog.NewError(fmt.Errorf("lpac not found\nPlease make sure you have put lpac binary in the `lpac` folder"), WMain)
d.SetOnClosed(func() {
os.Exit(127)
})
d.Show()
} else {
if version, err2 := LpacVersion(); err2 != nil {
LpacVersionLabel.SetText("lpac Version: unknown")
} else {
LpacVersionLabel.SetText("lpac Version: " + version)
}
RefreshApduDriver()
if ApduDrivers != nil {
ApduDriverSelect.SetSelectedIndex(0)
}
}
WMain.Show()
App.Run()
}