erm/app/darktile/config/config.go

41 lines
753 B
Go

package config
import (
"fmt"
"os"
"path"
)
type Font struct {
Family string `json:"family"`
Style string `json:"style"`
Size float64 `json:"size"`
DPI float64 `json:"dpi"`
Ligatures bool `json:"ligatures"`
}
type Cursor struct {
Image string `json:"image"`
}
type ErrorFileNotFound struct {
Path string `json:"path"`
}
func (e *ErrorFileNotFound) Error() string {
return fmt.Sprintf("file was not found at '%s'", e.Path)
}
func getConfigPath() (string, error) {
return getPath("term.star")
}
func getPath(filename string) (string, error) {
baseDir, err := os.UserConfigDir()
if err != nil {
return "", fmt.Errorf("config directory missing: %w", err)
}
return path.Join(baseDir, "term", filename), nil
}