-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (38 loc) · 770 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
package main
import (
"io"
"log"
"os"
"github.com/Shadowbeetle/skbl/backlight"
)
func main() {
var failCnt int
var inputFiles []io.Reader
inputPaths, idleWaitTime := readConfig()
for _, path := range inputPaths {
f, err := os.Open(path)
if err != nil {
log.Println("could not open input", path, err.Error())
failCnt += 1
continue
}
inputFiles = append(inputFiles, f)
}
if failCnt >= len(inputFiles) {
log.Fatalf("could not open any of the provided inputs %v", inputPaths)
}
conf := backlight.Config{
InputFiles: inputFiles,
IdleWaitTime: idleWaitTime,
}
kbl, err := backlight.NewKbdBacklight(conf)
if err != nil {
log.Fatal(err)
}
kbl.Run()
for err = range kbl.ErrorCh {
if err != nil {
log.Fatal(err)
}
}
}