refactor: restructure to standard Go project layout (cmd/ + internal/)
- Move entry point to cmd/streamdeck-lets-go/ - Split package main into internal packages: - internal/deck: hardware control (Deck, events, brightness) - internal/render: key rendering, icons, fonts, PageManager - internal/web: HTTP API + embedded SPA - internal/daemon: event loop, autoswitch, screensaver, actions - Add ConfigDir() to internal/config - Export cross-package API (Deck, PageManager, WebServer, etc.) - Move dist/arch/ → packaging/ with updated PKGBUILD/.SRCINFO - Add Makefile (build, test, vet, fmt, install) - Update README with new build commands and project structure - Delete unused media.go stub
This commit is contained in:
+34
-19
@@ -11,16 +11,16 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Version int `json:"version"`
|
||||
LogLevel string `json:"log_level"`
|
||||
DefaultPage string `json:"default_page"`
|
||||
Font string `json:"font,omitempty"`
|
||||
ShowLabelBackground bool `json:"show_label_background"`
|
||||
Devices []DeviceConfig `json:"devices"`
|
||||
Pages []PageConfig `json:"pages"`
|
||||
AutoSwitch []SwitchRule `json:"auto_switch"`
|
||||
Screensaver ScreensaverCfg `json:"screensaver"`
|
||||
Timing TimingConfig `json:"timing,omitempty"`
|
||||
Version int `json:"version"`
|
||||
LogLevel string `json:"log_level"`
|
||||
DefaultPage string `json:"default_page"`
|
||||
Font string `json:"font,omitempty"`
|
||||
ShowLabelBackground bool `json:"show_label_background"`
|
||||
Devices []DeviceConfig `json:"devices"`
|
||||
Pages []PageConfig `json:"pages"`
|
||||
AutoSwitch []SwitchRule `json:"auto_switch"`
|
||||
Screensaver ScreensaverCfg `json:"screensaver"`
|
||||
Timing TimingConfig `json:"timing,omitempty"`
|
||||
}
|
||||
|
||||
type TimingConfig struct {
|
||||
@@ -57,15 +57,15 @@ type DynamicKeyGen struct {
|
||||
}
|
||||
|
||||
type KeyConfig struct {
|
||||
Index int `json:"index"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Background string `json:"background,omitempty"`
|
||||
Label string `json:"label,omitempty"`
|
||||
Font string `json:"font,omitempty"`
|
||||
FontSize *float64 `json:"font_size,omitempty"`
|
||||
IconScale *float64 `json:"icon_scale,omitempty"`
|
||||
Actions []KeyAction `json:"actions,omitempty"`
|
||||
Display *DisplayCfg `json:"display,omitempty"`
|
||||
Index int `json:"index"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Background string `json:"background,omitempty"`
|
||||
Label string `json:"label,omitempty"`
|
||||
Font string `json:"font,omitempty"`
|
||||
FontSize *float64 `json:"font_size,omitempty"`
|
||||
IconScale *float64 `json:"icon_scale,omitempty"`
|
||||
Actions []KeyAction `json:"actions,omitempty"`
|
||||
Display *DisplayCfg `json:"display,omitempty"`
|
||||
}
|
||||
|
||||
type KeyAction struct {
|
||||
@@ -151,6 +151,21 @@ func ConfigPath(path string) string {
|
||||
return filepath.Join(home, ".config", "streamdeck-lets-go", "config.json")
|
||||
}
|
||||
|
||||
var cachedConfigDir string
|
||||
|
||||
func ConfigDir() string {
|
||||
if cachedConfigDir != "" {
|
||||
return cachedConfigDir
|
||||
}
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
cachedConfigDir = "."
|
||||
return cachedConfigDir
|
||||
}
|
||||
cachedConfigDir = filepath.Join(home, ".config", "streamdeck-lets-go")
|
||||
return cachedConfigDir
|
||||
}
|
||||
|
||||
func LoadConfig(path string) (*Config, error) {
|
||||
path = ConfigPath(path)
|
||||
data, err := os.ReadFile(path)
|
||||
|
||||
Reference in New Issue
Block a user