checkpointing, heavy dev
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
// Package config provides configuration management for hdmistat
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.eeqj.de/sneak/smartconfig"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultWidth = 1920
|
||||
defaultHeight = 1080
|
||||
)
|
||||
|
||||
// Config holds the application configuration
|
||||
type Config struct {
|
||||
FramebufferDevice string
|
||||
@@ -24,7 +31,7 @@ type Config struct {
|
||||
}
|
||||
|
||||
// Load loads configuration from all available sources
|
||||
func Load(ctx context.Context) (*Config, error) {
|
||||
func Load(_ context.Context) (*Config, error) {
|
||||
// Start with defaults
|
||||
cfg := &Config{
|
||||
FramebufferDevice: "/dev/fb0",
|
||||
@@ -32,8 +39,8 @@ func Load(ctx context.Context) (*Config, error) {
|
||||
UpdateInterval: "1s",
|
||||
Screens: []string{"overview", "top_cpu", "top_memory"},
|
||||
LogLevel: "info",
|
||||
Width: 1920,
|
||||
Height: 1080,
|
||||
Width: defaultWidth,
|
||||
Height: defaultHeight,
|
||||
}
|
||||
|
||||
// Try to load from the default location for hdmistat
|
||||
@@ -77,6 +84,11 @@ func Load(ctx context.Context) (*Config, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Override with environment variables if set
|
||||
if envLogLevel := os.Getenv("HDMISTAT_LOG_LEVEL"); envLogLevel != "" {
|
||||
cfg.LogLevel = envLogLevel
|
||||
}
|
||||
|
||||
// Parse durations
|
||||
cfg.rotationDuration, err = time.ParseDuration(cfg.RotationInterval)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user