feat: Enhance clipboard manager with logging, search, and status commands

This commit is contained in:
2025-05-20 21:51:39 +02:00
parent 1dad8ca69b
commit 71c7dd060f
12 changed files with 169 additions and 23 deletions

View File

@ -2,6 +2,8 @@ package config
import (
"os"
"os/user"
"path/filepath"
"gopkg.in/yaml.v3"
)
@ -10,12 +12,23 @@ type Config struct {
Logging struct {
Format string `yaml:"format"`
Level string `yaml:"level"`
Path string `yaml:"path"`
} `yaml:"logging"`
Clipboard struct {
MaxItems int `yaml:"max_items"`
} `yaml:"clipboard"`
}
func logFilePath() string {
usr, err := user.Current()
if err != nil {
return "./kcm.log"
}
dir := filepath.Join(usr.HomeDir, ".local", "share", "kcm")
os.MkdirAll(dir, 0700)
return filepath.Join(dir, "kcm.log")
}
func LoadConfig() (Config, string) {
paths := []string{"/etc/kcm/config.yml", "./config.yml"}
var cfg Config
@ -30,7 +43,9 @@ func LoadConfig() (Config, string) {
return cfg, path
}
}
cfg.Logging.Format = "console"
cfg.Logging.Level = "info"
cfg.Logging.Path = logFilePath()
return cfg, ""
}