-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (41 loc) · 835 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
52
53
package main
import (
json "encoding/json"
fmt "fmt"
os "os"
)
import (
initier "chdad/initier"
deviceManager "chdad/deviceManager"
)
var (
config *initier.Config
)
func init() {
initier.InitAll()
file, _ := os.ReadFile(initier.CONFIG_PATH)
err := json.Unmarshal(file, &config)
if err != nil {
panic(err)
}
}
func main() {
CUR := deviceManager.GetCUR()
switch CUR {
// if speaker (0)
case "0": {
deviceManager.Switch(config.Device.Headset)
os.WriteFile(initier.CUR_PATH, []byte("1"), 0644)
}
// if headset (1)
case "1": {
deviceManager.Switch(config.Device.Speaker)
os.WriteFile(initier.CUR_PATH, []byte("0"), 0644)
}
// if not valid
default: {
initier.InitCUR()
fmt.Printf("%v\n", &initier.CURFileParseWarning{})
}
}
}