package rgb import ( "fmt" "os" "github.com/spf13/cobra" "github.com/wobkey/rgb/internal/rgb" "github.com/wobkey/rgb/internal/via" ) func NewSpeedCmd() *cobra.Command { return &cobra.Command{ Use: "speed ", Short: "Set effect speed", Long: "Set the RGB effect speed value (0-255).", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { val, err := ParseUint8(args[0]) if err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) os.Exit(1) } 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.Speed), val); err != nil { fmt.Fprintf(os.Stderr, "Error setting speed: %v\n", err) os.Exit(1) } fmt.Printf("Speed set to %d\n", val) }, } }