-
Notifications
You must be signed in to change notification settings - Fork 10
/
config.go
86 lines (81 loc) · 3.12 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
import (
"encoding/json"
"io/ioutil"
"os/user"
)
// Config Struct for Configuration File
type Config struct {
Format []string `json:"format"` // Format Array for Modules
ShowASCII bool `json:"showAscii"` // True/False to Display ASCII
UseDefaultColors bool `json:"useDefaultColors"` // Use Default Colors
UseSmallASCII bool `json:"useSmallAscii"` // Use Small ASCII Art
ASCIIColor string `json:"asciiColor"` // Change ASCII Color
UseCustomASCII bool `json:"useCustomAscii"` // Use Custom ASCII TRUE/FALSE
CustomASCIIPath string `json:"customAsciiPath"` // Absolute Path to Custom ASCII
UserColor string `json:"userColor"` // Color for Username
SepColor string `json:"sepColor"` // Color for Separator
TitleColor string `json:"titleColor"` // Color for Title
InfoColor string `json:"infoColor"` // Color for Information
Titles TitleValues `json:"titles"` // Title Struct
AutoUpdate bool `json:"autoupdate"` // Should Auto Update?
Version int64 `json:"configVersion"` // Configuration Version
}
// TitleValues Struct for Title Strings
type TitleValues struct {
Memory string `json:"memory"`
CPU string `json:"cpu"`
CPUCores string `json:"cpuCores"`
CPUThreads string `json:"cpuThreads"`
GPUs string `json:"gpus"`
DiskSize string `json:"diskSize"`
WindowsVersion string `json:"windowsVersion"`
Bios string `json:"bios"`
Baseboard string `json:"baseboard"`
ProcessCount string `json:"processCount"`
Uptime string `json:"uptime"`
Network string `json:"network"`
}
func updateConfig(config Config) {
user, _ := user.Current()
if config.Version == 0 {
config.AutoUpdate = true
config.Version = 1
}
if config.Version == 1 {
config.Titles.Network = "Local IP"
config.Format = append(config.Format, "network")
config.Version = 2
}
file, _ := json.MarshalIndent(config, "", " ")
_ = ioutil.WriteFile(user.HomeDir+"\\.winfetch.json", file, 0644)
}
func newConfig() Config {
config := Config{}
config.Format = []string{"user", "sep", "uptime", "mem", "cpu", "procs", "cpuCores", "cpuThreads", "disk", "wversion", "gpus", "bios", "baseboard", "network"}
config.ShowASCII = true
config.UseSmallASCII = false
config.UseCustomASCII = false
config.CustomASCIIPath = ""
config.UseDefaultColors = true
config.ASCIIColor = "Blue"
config.UserColor = "Red"
config.SepColor = "Red"
config.TitleColor = "Green"
config.InfoColor = "White"
config.Titles.Memory = "Memory"
config.Titles.CPUCores = "CPU Cores"
config.Titles.CPUThreads = "CPU Threads"
config.Titles.GPUs = "GPU #"
config.Titles.DiskSize = "Disk Size"
config.Titles.WindowsVersion = "Windows Ver."
config.Titles.Bios = "BIOS"
config.Titles.Baseboard = "Baseboard"
config.Titles.Uptime = "Uptime"
config.Titles.ProcessCount = "Processes"
config.Titles.CPU = "CPU #"
config.Titles.Network = "Local IP"
config.AutoUpdate = true
config.Version = 1
return config
}