erm/app/darktile/config/config.go

41 lines
753 B
Go
Raw Normal View History

2021-07-30 22:29:20 +00:00
package config
import (
"fmt"
"os"
"path"
)
type Font struct {
2023-01-16 02:07:04 +00:00
Family string `json:"family"`
2023-01-16 06:03:38 +00:00
Style string `json:"style"`
2023-01-16 02:07:04 +00:00
Size float64 `json:"size"`
DPI float64 `json:"dpi"`
Ligatures bool `json:"ligatures"`
}
type Cursor struct {
2023-01-16 02:07:04 +00:00
Image string `json:"image"`
2021-07-30 22:29:20 +00:00
}
type ErrorFileNotFound struct {
2023-01-16 02:07:04 +00:00
Path string `json:"path"`
2021-07-30 22:29:20 +00:00
}
func (e *ErrorFileNotFound) Error() string {
return fmt.Sprintf("file was not found at '%s'", e.Path)
}
func getConfigPath() (string, error) {
2024-02-07 23:43:18 +00:00
return getPath("term.star")
2021-07-30 22:29:20 +00:00
}
func getPath(filename string) (string, error) {
baseDir, err := os.UserConfigDir()
if err != nil {
return "", fmt.Errorf("config directory missing: %w", err)
}
2024-02-07 23:43:18 +00:00
return path.Join(baseDir, "term", filename), nil
2021-07-30 22:29:20 +00:00
}