| 12345678910111213141516171819202122232425262728293031323334353637 |
- package rgb
- import (
- "fmt"
- "os"
- "github.com/spf13/cobra"
- "github.com/wobkey/rgb/internal/rgb"
- "github.com/wobkey/rgb/internal/via"
- )
- func NewEnableCmd() *cobra.Command {
- return &cobra.Command{
- Use: "enable",
- Short: "Enable RGB lighting",
- Run: func(cmd *cobra.Command, args []string) {
- proto, _, err := OpenDevice()
- if err != nil {
- fmt.Fprintf(os.Stderr, "Error: %v\n", err)
- os.Exit(1)
- }
- defer proto.Close()
- if err := proto.EnableHandshake(); err != nil {
- fmt.Fprintf(os.Stderr, "Handshake failed: %v\n", err)
- os.Exit(1)
- }
- if err := proto.SetValue(via.RGBLight, uint8(rgb.Enable), 1); err != nil {
- fmt.Fprintf(os.Stderr, "Error enabling RGB: %v\n", err)
- os.Exit(1)
- }
- fmt.Println("RGB enabled")
- },
- }
- }
|