Documentation
¶
Overview ¶
Package config handles platform-specific configuration for sensorpanel.
Configuration is stored in platform-specific locations:
- Linux: $XDG_CONFIG_HOME/sensorpanel/config.json (default: ~/.config/sensorpanel/)
- macOS: ~/Library/Application Support/sensorpanel/config.json
- Windows: %APPDATA%\sensorpanel\config.json
The config file stores:
- Selected USB device (VID, PID, Serial)
- Display settings (brightness, etc.)
Package config provides USB device discovery for sensorpanel.
Index ¶
- func ConfigPath() (string, error)
- func GetProfileID() (string, error)
- func GetTheme() (string, error)
- func Save(cfg *Config) error
- func SetDevice(vid, pid uint16, serial string) error
- func SetProfileID(profileID string) error
- func SetTheme(themeName string) error
- type Config
- type DiscoveredDevice
- type USBDevice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigPath ¶
ConfigPath returns the full path to the config file.
func GetProfileID ¶
GetProfileID returns the currently configured device profile ID.
func SetProfileID ¶
SetProfileID updates the device profile ID and saves the config.
Types ¶
type Config ¶
type Config struct {
// Selected USB display device
Device USBDevice `json:"device"`
// Device profile ID (e.g., "qtkeji", "generic")
// If empty, profile is auto-detected from VID/PID
ProfileID string `json:"profile_id,omitempty"`
// Display settings
Brightness int `json:"brightness,omitempty"` // 0-7, default 7
// Theme settings
Theme string `json:"theme,omitempty"` // Active theme name (empty = use built-in renderer)
// Sensor settings
UpdateInterval float64 `json:"update_interval,omitempty"` // seconds
SensorOptions map[string]interface{} `json:"sensor_options,omitempty"` // Provider-specific options (e.g., "disk.mounts": ["/", "/home"])
}
Config represents the application configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a config with sensible defaults. Note: Device is not set - user must select a device first.
type DiscoveredDevice ¶
type DiscoveredDevice struct {
VendorID uint16
ProductID uint16
Manufacturer string
Product string
Serial string
Speed string
BusAddr string // Bus:Address for identification
IsProbable bool // Likely to be a display panel based on heuristics
}
DiscoveredDevice represents a USB device found during scanning.
func AutoDetectOrPrompt ¶
func AutoDetectOrPrompt() (*DiscoveredDevice, bool, error)
AutoDetectOrPrompt tries to find a display device automatically. Returns the device to use, whether user interaction was needed, and any error.
func DiscoverDevices ¶
func DiscoverDevices(knownOnly bool) ([]DiscoveredDevice, error)
DiscoverDevices scans USB bus for potential display devices. If knownOnly is true, only returns devices matching KnownDisplayVendors. Otherwise, uses heuristics to find probable display devices.
func FindConfiguredDevice ¶
func FindConfiguredDevice() (*DiscoveredDevice, error)
FindConfiguredDevice attempts to find and validate the configured device. Returns the discovered device info if found, or an error if not found.
func (DiscoveredDevice) String ¶
func (d DiscoveredDevice) String() string
String returns a human-readable description.
func (DiscoveredDevice) ToUSBDevice ¶
func (d DiscoveredDevice) ToUSBDevice() USBDevice
ToUSBDevice converts to a USBDevice for config storage.
type USBDevice ¶
type USBDevice struct {
VendorID uint16 `json:"vendor_id"`
ProductID uint16 `json:"product_id"`
Serial string `json:"serial,omitempty"` // Optional: disambiguate multiple identical devices
}
USBDevice represents a USB device identifier.