You've already forked panic-cli
mirror of
https://github.com/Print-and-Panic/panic-cli.git
synced 2026-01-21 10:17:41 -08:00
feat(persona): Set RGB on personal rig
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/Print-and-Panic/panic-cli/internal/config"
|
||||
"github.com/Print-and-Panic/panic-cli/internal/git"
|
||||
"github.com/Print-and-Panic/panic-cli/internal/platform"
|
||||
"github.com/Print-and-Panic/panic-cli/internal/system"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
@@ -79,6 +80,13 @@ func setPersona(persona config.PersonaConfig) error {
|
||||
fmt.Printf("❌ Failed to set KDE Theme: %v\n", err)
|
||||
}
|
||||
|
||||
if sc, ok := system.CurrentSystem.(platform.StudioController); ok && persona.StudioPreset != "" {
|
||||
err = sc.ApplyStudioPreset(persona.StudioPreset)
|
||||
if err != nil {
|
||||
fmt.Printf("❌ Failed to apply Studio Preset: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ var RootCmd = &cobra.Command{
|
||||
system.CurrentSystem = &platform.MockSystem{}
|
||||
fmt.Println("⚠️ Running in DRY-RUN mode. No changes will be applied.")
|
||||
} else {
|
||||
system.CurrentSystem = &platform.LinuxKDE{}
|
||||
system.CurrentSystem = &platform.PersonalRig{}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
1
go.mod
1
go.mod
@@ -15,6 +15,7 @@ require (
|
||||
cloud.google.com/go/auth v0.17.0 // indirect
|
||||
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.9.0 // indirect
|
||||
github.com/Alatec/go-openrgb v0.1.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
|
||||
2
go.sum
2
go.sum
@@ -6,6 +6,8 @@ cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIi
|
||||
cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c=
|
||||
cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs=
|
||||
cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10=
|
||||
github.com/Alatec/go-openrgb v0.1.0 h1:RR3a7YGQwKM3crjEWmSiKR3eshwV357m+yQS7tlWYUg=
|
||||
github.com/Alatec/go-openrgb v0.1.0/go.mod h1:0yk6Bq2hOY9icPj/zRkywt431BtzjFee2FiTH4P53mw=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
|
||||
@@ -3,10 +3,11 @@ package config
|
||||
var AppConfig Config
|
||||
|
||||
type PersonaConfig struct {
|
||||
GitName string `mapstructure:"git_name"`
|
||||
GitEmail string `mapstructure:"git_email"`
|
||||
KdeTheme string `mapstructure:"kde_theme"`
|
||||
Wallpaper string `mapstructure:"wallpaper"`
|
||||
GitName string `mapstructure:"git_name"`
|
||||
GitEmail string `mapstructure:"git_email"`
|
||||
KdeTheme string `mapstructure:"kde_theme"`
|
||||
Wallpaper string `mapstructure:"wallpaper"`
|
||||
StudioPreset string `mapstructure:"studio_preset"`
|
||||
}
|
||||
|
||||
type PersonaManagement struct {
|
||||
|
||||
@@ -17,3 +17,7 @@ type System interface {
|
||||
GitIdentityProvider
|
||||
ThemeHandler
|
||||
}
|
||||
|
||||
type StudioController interface {
|
||||
ApplyStudioPreset(string) error
|
||||
}
|
||||
|
||||
32
internal/platform/personal_rig.go
Normal file
32
internal/platform/personal_rig.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package platform
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Alatec/go-openrgb"
|
||||
)
|
||||
|
||||
var _ StudioController = (*PersonalRig)(nil)
|
||||
|
||||
type PersonalRig struct {
|
||||
LinuxKDE
|
||||
}
|
||||
|
||||
func (p *PersonalRig) ApplyStudioPreset(persona string) error {
|
||||
client := openrgb.NewOpenRGBClient()
|
||||
client.Connect("localhost:6742")
|
||||
defer client.Disconnect()
|
||||
|
||||
profiles, err := client.ListProfiles()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, profile := range profiles {
|
||||
if profile == persona {
|
||||
return client.LoadProfile(profile)
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("profile '%s' not found", persona)
|
||||
}
|
||||
Reference in New Issue
Block a user