Skip to content

Commit c6b70fb

Browse files
committed
chore: add effects command tool
1 parent 0245819 commit c6b70fb

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

cmd/effects/main.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Example app for working with keyboard light effects
2+
package main
3+
4+
import (
5+
"fmt"
6+
7+
"github.com/mishamyrt/nuga-lib"
8+
"github.com/mishamyrt/nuga-lib/packages/cli"
9+
)
10+
11+
var app = cli.App{
12+
Name: "nuga-effects",
13+
Help: "Utility for workings with keyboard light effects",
14+
}
15+
16+
var (
17+
cmdDescribe = cli.Command{
18+
Name: "describe",
19+
Help: "Print current keyboard lights effects",
20+
Run: func(_ []string) {
21+
dev, err := nuga.Open()
22+
cli.Must("open device", err)
23+
effects, err := dev.Features.Light.GetEffects()
24+
cli.Must("get effects", err)
25+
fmt.Println("Backlight")
26+
fmt.Printf(" Mode: %v\n", effects.Backlight.Mode.Name)
27+
fmt.Printf(" Color: %v\n", effects.Backlight.CurrentParams().Color)
28+
fmt.Printf(" Brightness: %v\n", effects.Backlight.CurrentParams().Brightness)
29+
fmt.Printf(" Speed: %v\n", effects.Backlight.CurrentParams().Speed)
30+
fmt.Println("Halo")
31+
fmt.Printf(" Mode: %v\n", effects.Halo.Mode.Name)
32+
fmt.Printf(" Color: %v\n", effects.Halo.Color)
33+
fmt.Printf(" Brightness: %v\n", effects.Halo.Brightness)
34+
fmt.Printf(" Speed: %v\n", effects.Halo.Speed)
35+
fmt.Println("Sidelight")
36+
fmt.Printf(" Mode: %v\n", effects.Sidelight.Mode.Name)
37+
fmt.Printf(" Color: %v\n", effects.Sidelight.Color)
38+
fmt.Printf(" Brightness: %v\n", effects.Sidelight.Brightness)
39+
fmt.Printf(" Speed: %v\n", effects.Sidelight.Speed)
40+
},
41+
}
42+
)
43+
44+
func init() {
45+
err := nuga.Init()
46+
cli.Must("initialize CLI", err)
47+
}
48+
49+
func main() {
50+
cli.Must("initialize connection", nuga.Init())
51+
app.RunWith(cmdDescribe)
52+
cli.Must("close connection", nuga.Exit())
53+
}

0 commit comments

Comments
 (0)