forked from muesli/streamdeck
/
main.go
51 lines (43 loc) · 847 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 (
"fmt"
"log"
"os"
"github.com/unix-streamdeck/streamdeck"
"github.com/spf13/cobra"
)
var (
// RootCmd is the core command used for cli-arg parsing
RootCmd = &cobra.Command{
Use: "streamdeck-cli",
Short: "streamdeck-cli lets you control your Elgato Stream Deck",
SilenceErrors: true,
SilenceUsage: true,
}
d streamdeck.Device
)
func main() {
devs, err := streamdeck.Devices()
if err != nil {
panic(err)
}
if len(devs) == 0 {
log.Fatalln("No Stream Deck devices found.")
}
d = devs[0]
err = d.Open()
if err != nil {
panic(err)
}
defer d.Close()
ver, err := d.FirmwareVersion()
if err != nil {
panic(err)
}
fmt.Printf("Found device with serial %s (firmware %s)\n",
d.Serial, ver)
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(-1)
}
}