-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
52 lines (46 loc) · 997 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"image/color"
"io/ioutil"
yaml "gopkg.in/yaml.v2"
)
type Config struct {
WallpaperDir string
TextDrawerEnabled bool
LastUpdate int64
TextDrawerConfig TextDrawerConfig
}
func (c Config) Save(filename string) {
y, err := yaml.Marshal(c)
if err != nil {
panic(err)
}
ioutil.WriteFile(filename, y, 0644)
}
func (c *Config) Load(filename string) {
b, err := ioutil.ReadFile(filename)
if err != nil {
panic(err)
}
err = yaml.Unmarshal(b, c)
if err != nil {
panic(err)
}
}
func Default() Config {
return Config{
TextDrawerConfig: TextDrawerConfig{
FontFile: "C:/Windows/Fonts/simsun.ttc",
FontSize: 20,
TextWidth: 100,
LineSpacing: 2,
OffsetX: 1500,
OffsetY: 50,
TextColor: color.RGBA{255, 255, 255, 255},
BackgroundColor: color.RGBA{R: 0, G: 0, B: 0, A: 100},
BackgroundPadding: 16,
},
WallpaperDir: "./",
TextDrawerEnabled: true,
}
}