refactor: move backend options into backend_config section
- Add BackendConfig map[string]any to Config struct - Deprecate top-level output_path (backward compatible via EffectiveBackendConfig()) - NewHyprland now accepts opts map[string]any instead of raw outputPath - Factory signature unified to func(*slog.Logger, map[string]any) for all backends - Update README with backend_config docs and fix Sway skeleton signature - Update example.yaml to show backend_config instead of output_path
This commit is contained in:
@@ -30,6 +30,7 @@ type hyprlandBackend struct {
|
||||
|
||||
// outputPath overrides the generated monitor config file path.
|
||||
// Empty means the default: ~/.config/hypr/monitors.conf.
|
||||
// Read from backend_config.output_path at construction time.
|
||||
outputPath string
|
||||
|
||||
// conn is the current socket2 connection; guarded by mu.
|
||||
@@ -40,9 +41,12 @@ type hyprlandBackend struct {
|
||||
// NewHyprland creates a Hyprland backend. The backend auto-detects the
|
||||
// Hyprland instance signature from the environment.
|
||||
//
|
||||
// outputPath overrides the generated monitor config file location.
|
||||
// When empty, defaults to ~/.config/hypr/monitors.conf.
|
||||
func NewHyprland(logger *slog.Logger, outputPath string) (Backend, error) {
|
||||
// opts carries backend-specific configuration from the config file's
|
||||
// backend_config section. Hyprland supports:
|
||||
//
|
||||
// output_path — path to the generated monitor config file
|
||||
// (default: ~/.config/hypr/monitors.conf)
|
||||
func NewHyprland(logger *slog.Logger, opts map[string]any) (Backend, error) {
|
||||
sig := os.Getenv("HYPRLAND_INSTANCE_SIGNATURE")
|
||||
if sig == "" {
|
||||
return nil, errors.New("HYPRLAND_INSTANCE_SIGNATURE is not set; is Hyprland running?")
|
||||
@@ -57,6 +61,13 @@ func NewHyprland(logger *slog.Logger, outputPath string) (Backend, error) {
|
||||
return nil, fmt.Errorf("socket2 not found at %s: %w", socketPath, err)
|
||||
}
|
||||
|
||||
var outputPath string
|
||||
if opts != nil {
|
||||
if v, ok := opts["output_path"]; ok {
|
||||
outputPath, _ = v.(string)
|
||||
}
|
||||
}
|
||||
|
||||
return &hyprlandBackend{logger: logger, outputPath: outputPath}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user