package rgb import ( "fmt" "os" "github.com/spf13/cobra" "github.com/wobkey/rgb/internal/rgb" "github.com/wobkey/rgb/internal/via" ) func NewEffectCmd() *cobra.Command { return &cobra.Command{ Use: "effect ", Short: "Set RGB effect", Long: "Set the RGB lighting effect on the connected keyboard.", Args: cobra.ExactArgs(1), 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() e, err := rgb.ParseImpact80Effect(args[0]) if err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) os.Exit(1) } if err := proto.SetValue(via.RGBLight, uint8(rgb.EffectID), e); err != nil { fmt.Fprintf(os.Stderr, "Error setting effect: %v\n", err) os.Exit(1) } fmt.Printf("Effect set to %q\n", args[0]) }, } }