| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- package rgb
- import (
- "fmt"
- "os"
- "github.com/spf13/cobra"
- "github.com/wobkey/rgb/internal/rgb"
- "github.com/wobkey/rgb/internal/via"
- )
- func NewModeCmd() *cobra.Command {
- return &cobra.Command{
- Use: "mode <index>",
- Short: "Set effect mode by index",
- Long: "Set the RGB effect mode by numeric index (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.SetValue(via.RGBLight, uint8(rgb.EffectID), val); err != nil {
- fmt.Fprintf(os.Stderr, "Error setting mode: %v\n", err)
- os.Exit(1)
- }
- fmt.Printf("Mode set to index %d\n", val)
- },
- }
- }
|