37 lines
741 B
Go
37 lines
741 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"github.com/adhocore/jsonc"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
ImageFilters
|
|
ImagesDir string
|
|
Duration int
|
|
Cache string
|
|
}
|
|
|
|
func (config *Config) load() {
|
|
configRaw, err := os.ReadFile("./config.jsonc")
|
|
if err != nil {
|
|
log.Fatal("Couldn't open config file!\n", err)
|
|
}
|
|
j := jsonc.New()
|
|
configRaw = j.Strip(configRaw)
|
|
err = json.Unmarshal(configRaw, &config)
|
|
if err != nil {
|
|
log.Fatal("Couldn't unmarshal config!\n", err)
|
|
}
|
|
|
|
homeDir, err := os.UserHomeDir()
|
|
if err != nil {
|
|
log.Fatal("could not get home directory!", err)
|
|
}
|
|
config.Cache = homeDir + "/" + config.Cache + "/"
|
|
//TODO: make directories if they don't
|
|
config.ImagesDir = homeDir + "/" + config.ImagesDir + "/"
|
|
}
|