Always setup default values even if module that uses it is disabled

This commit is contained in:
eleksir
2024-09-13 23:27:36 +03:00
parent 1485354b6c
commit 03926f47c4

332
config.go
View File

@@ -13,6 +13,26 @@ import (
"github.com/hjson/hjson-go" "github.com/hjson/hjson-go"
) )
type Separator struct {
Left struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"left,omitempty"`
Right struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"right,omitempty"`
}
type MyConfig struct { type MyConfig struct {
// Default text color // Default text color
@@ -27,25 +47,7 @@ type MyConfig struct {
// Default text font size // Default text font size
FontSize string `json:"font_size,omitempty"` FontSize string `json:"font_size,omitempty"`
Separator struct { Separator Separator `json:"separator,omitempty"`
Left struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"left,omitempty"`
Right struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"right,omitempty"`
} `json:"separator,omitempty"`
// LA Plugin // LA Plugin
LA struct { LA struct {
@@ -54,26 +56,7 @@ type MyConfig struct {
Background string `json:"background,omitempty"` Background string `json:"background,omitempty"`
Font string `json:"font,omitempty"` Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"` FontSize string `json:"font_size,omitempty"`
Separator Separator `json:"la,omitempty"`
Separator struct {
Left struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"left,omitempty"`
Right struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"right,omitempty"`
} `json:"separator,omitempty"`
} `json:"la,omitempty"` } `json:"la,omitempty"`
// Mem plugin // Mem plugin
@@ -84,25 +67,7 @@ type MyConfig struct {
Font string `json:"font,omitempty"` Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"` FontSize string `json:"font_size,omitempty"`
ShowSwap bool `json:"show_swap,omitempty"` ShowSwap bool `json:"show_swap,omitempty"`
Separator Separator `json:"separator,omitempty"`
Separator struct {
Left struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"left,omitempty"`
Right struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"right,omitempty"`
} `json:"separator,omitempty"`
} `json:"mem,omitempty"` } `json:"mem,omitempty"`
Clock struct { Clock struct {
@@ -111,25 +76,7 @@ type MyConfig struct {
Background string `json:"background,omitempty"` Background string `json:"background,omitempty"`
Font string `json:"font,omitempty"` Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"` FontSize string `json:"font_size,omitempty"`
Separator Separator `json:"separator,omitempty"`
Separator struct {
Left struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"left,omitempty"`
Right struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"right,omitempty"`
} `json:"separator,omitempty"`
LeftClick struct { LeftClick struct {
Enabled bool `json:"enabled,omitempty"` Enabled bool `json:"enabled,omitempty"`
@@ -159,24 +106,7 @@ type MyConfig struct {
AlmostEmpty string `json:"almost_empty,omitempty"` AlmostEmpty string `json:"almost_empty,omitempty"`
} `json:"charge_color,omitempty"` } `json:"charge_color,omitempty"`
Separator struct { Separator Separator `json:"separator,omitempty"`
Left struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"left,omitempty"`
Right struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"right,omitempty"`
} `json:"separator,omitempty"`
} `json:"battery,omitempty"` } `json:"battery,omitempty"`
CPUTemp struct { CPUTemp struct {
@@ -185,26 +115,7 @@ type MyConfig struct {
Background string `json:"background,omitempty"` Background string `json:"background,omitempty"`
Font string `json:"font,omitempty"` Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"` FontSize string `json:"font_size,omitempty"`
Separator Separator `json:"separator,omitempty"`
Separator struct {
Left struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"left,omitempty"`
Right struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"right,omitempty"`
} `json:"separator,omitempty"`
File []string `json:"file,omitempty"` File []string `json:"file,omitempty"`
} `json:"cpu_temp,omitempty"` } `json:"cpu_temp,omitempty"`
@@ -219,25 +130,7 @@ type MyConfig struct {
MtimeThreshold int `json:"mtime_threshold,omitempty"` MtimeThreshold int `json:"mtime_threshold,omitempty"`
DownColor string `json:"down_color,omitempty"` DownColor string `json:"down_color,omitempty"`
UpColor string `json:"up_color,omitempty"` UpColor string `json:"up_color,omitempty"`
Separator Separator `json:"separator,omitempty"`
Separator struct {
Left struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"left,omitempty"`
Right struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"right,omitempty"`
} `json:"separator,omitempty"`
TCPCheck struct { TCPCheck struct {
Enabled bool `json:"enabled,omitempty"` Enabled bool `json:"enabled,omitempty"`
@@ -257,25 +150,7 @@ type MyConfig struct {
SymbolFont string `json:"symbol_font,omitempty"` SymbolFont string `json:"symbol_font,omitempty"`
SymbolFontSize string `json:"symbol_font_size,omitempty"` SymbolFontSize string `json:"symbol_font_size,omitempty"`
DontExitOnLogin bool `json:"dont_exit_on_login,omitempty"` DontExitOnLogin bool `json:"dont_exit_on_login,omitempty"`
Separator Separator `json:"separator,omitempty"`
Separator struct {
Left struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"left,omitempty"`
Right struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"right,omitempty"`
} `json:"separator,omitempty"`
Step int `json:"step,omitempty"` Step int `json:"step,omitempty"`
RightClickCmd []string `json:"right_click_cmd,omitempty"` RightClickCmd []string `json:"right_click_cmd,omitempty"`
@@ -292,25 +167,7 @@ type MyConfig struct {
Background string `json:"background,omitempty"` Background string `json:"background,omitempty"`
Font string `json:"font,omitempty"` Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"` FontSize string `json:"font_size,omitempty"`
Separator Separator `json:"separator,omitempty"`
Separator struct {
Left struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"left,omitempty"`
Right struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"right,omitempty"`
} `json:"separator,omitempty"`
If []struct { If []struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
@@ -330,25 +187,7 @@ type MyConfig struct {
AppButtons struct { AppButtons struct {
Enabled bool `json:"enabled,omitempty"` Enabled bool `json:"enabled,omitempty"`
Separator Separator `json:"separator,omitempty"`
Separator struct {
Left struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"left,omitempty"`
Right struct {
Enabled bool `json:"enabled,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Symbol string `json:"symbol,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
} `json:"right,omitempty"`
} `json:"separator,omitempty"`
} `json:"app_buttons,omitempty"` } `json:"app_buttons,omitempty"`
Apps []struct { Apps []struct {
@@ -464,13 +303,13 @@ func readConf() (MyConfig, error) {
sampleConfig.FontSize = "medium" sampleConfig.FontSize = "medium"
} }
if sampleConfig.Separator.Left.Enabled { // Even if separator is disabled fallback values should be filled in.
if sampleConfig.Separator.Left.Color == "" { if sampleConfig.Separator.Left.Color == "" {
sampleConfig.Separator.Left.Color = "#edeceb" sampleConfig.Separator.Left.Color = sampleConfig.Color
} }
if sampleConfig.Separator.Left.Background == "" { if sampleConfig.Separator.Left.Background == "" {
sampleConfig.Separator.Left.Background = "#3e78fd" sampleConfig.Separator.Left.Background = sampleConfig.Background
} }
if sampleConfig.Separator.Left.Symbol == "" { if sampleConfig.Separator.Left.Symbol == "" {
@@ -478,7 +317,7 @@ func readConf() (MyConfig, error) {
} }
if sampleConfig.Separator.Left.Font == "" { if sampleConfig.Separator.Left.Font == "" {
sampleConfig.Separator.Left.Font = "Noto Sans" sampleConfig.Separator.Left.Font = sampleConfig.Font
} }
matched, err := regexp.MatchString( matched, err := regexp.MatchString(
@@ -505,15 +344,14 @@ func readConf() (MyConfig, error) {
sampleConfig.Separator.Left.FontSize = sampleConfig.FontSize sampleConfig.Separator.Left.FontSize = sampleConfig.FontSize
} }
}
if sampleConfig.Separator.Right.Enabled { // Even if separator is disabled fallback values should be filled in.
if sampleConfig.Separator.Right.Color == "" { if sampleConfig.Separator.Right.Color == "" {
sampleConfig.Separator.Right.Color = "#edeceb" sampleConfig.Separator.Right.Color = sampleConfig.Color
} }
if sampleConfig.Separator.Right.Background == "" { if sampleConfig.Separator.Right.Background == "" {
sampleConfig.Separator.Right.Background = "#3e78fd" sampleConfig.Separator.Right.Background = sampleConfig.Background
} }
if sampleConfig.Separator.Right.Symbol == "" { if sampleConfig.Separator.Right.Symbol == "" {
@@ -521,10 +359,10 @@ func readConf() (MyConfig, error) {
} }
if sampleConfig.Separator.Right.Font == "" { if sampleConfig.Separator.Right.Font == "" {
sampleConfig.Separator.Right.Font = "Noto Sans" sampleConfig.Separator.Right.Font = sampleConfig.Font
} }
matched, err := regexp.MatchString( matched, err = regexp.MatchString(
`^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger)$`, `^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger)$`,
sampleConfig.Separator.Right.FontSize, sampleConfig.Separator.Right.FontSize,
) )
@@ -547,11 +385,7 @@ func readConf() (MyConfig, error) {
sampleConfig.Separator.Right.FontSize = sampleConfig.FontSize sampleConfig.Separator.Right.FontSize = sampleConfig.FontSize
} }
}
// sampleConfig.LA will be false if not set in config
if sampleConfig.LA.Enabled {
if sampleConfig.LA.Separator.Left.Enabled {
if sampleConfig.LA.Separator.Left.Color == "" { if sampleConfig.LA.Separator.Left.Color == "" {
sampleConfig.LA.Separator.Left.Color = sampleConfig.Separator.Left.Color sampleConfig.LA.Separator.Left.Color = sampleConfig.Separator.Left.Color
} }
@@ -595,23 +429,21 @@ func readConf() (MyConfig, error) {
sampleConfig.LA.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize sampleConfig.LA.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize
} }
} }
if sampleConfig.LA.Separator.Right.Color == "" {
sampleConfig.LA.Separator.Right.Color = sampleConfig.Separator.Right.Color
} }
if sampleConfig.LA.Separator.Right.Enabled { if sampleConfig.LA.Separator.Right.Background == "" {
if sampleConfig.LA.Color == "" { sampleConfig.LA.Separator.Right.Background = sampleConfig.Separator.Right.Background
sampleConfig.LA.Color = sampleConfig.Color
} }
if sampleConfig.LA.Background == "" { if sampleConfig.LA.Separator.Right.Font == "" {
sampleConfig.LA.Background = sampleConfig.Background sampleConfig.LA.Separator.Right.Font = sampleConfig.Separator.Right.Font
} }
if sampleConfig.LA.Font == "" { if sampleConfig.LA.Separator.Right.FontSize == "" {
sampleConfig.LA.Font = sampleConfig.Font sampleConfig.LA.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
}
if sampleConfig.LA.FontSize == "" {
sampleConfig.LA.FontSize = sampleConfig.FontSize
} }
if sampleConfig.LA.Separator.Right.Color == "" { if sampleConfig.LA.Separator.Right.Color == "" {
@@ -657,11 +489,7 @@ func readConf() (MyConfig, error) {
sampleConfig.LA.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize sampleConfig.LA.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
} }
} }
}
}
// sampleConfig.Mem will be false if not set in config
if sampleConfig.Mem.Enabled {
if sampleConfig.Mem.Color == "" { if sampleConfig.Mem.Color == "" {
sampleConfig.Mem.Color = sampleConfig.Color sampleConfig.Mem.Color = sampleConfig.Color
} }
@@ -722,7 +550,6 @@ func readConf() (MyConfig, error) {
} }
} }
if sampleConfig.Mem.Separator.Right.Enabled {
if sampleConfig.Mem.Separator.Right.Color == "" { if sampleConfig.Mem.Separator.Right.Color == "" {
sampleConfig.Mem.Separator.Right.Color = sampleConfig.Separator.Right.Color sampleConfig.Mem.Separator.Right.Color = sampleConfig.Separator.Right.Color
} }
@@ -751,7 +578,7 @@ func readConf() (MyConfig, error) {
log.Printf( log.Printf(
"Unable to set sampleConfig.Mem.Separator.Right.FontSize: %s, fallback to %s", "Unable to set sampleConfig.Mem.Separator.Right.FontSize: %s, fallback to %s",
err, err,
sampleConfig.Mem.Separator.Right.FontSize, sampleConfig.Separator.Right.FontSize,
) )
sampleConfig.Mem.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize sampleConfig.Mem.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
@@ -766,11 +593,7 @@ func readConf() (MyConfig, error) {
sampleConfig.Mem.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize sampleConfig.Mem.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
} }
} }
}
}
// sampleConfig.Clock.Enabled will be false if not set in config
if sampleConfig.Clock.Enabled {
if sampleConfig.Clock.Color == "" { if sampleConfig.Clock.Color == "" {
sampleConfig.Clock.Color = sampleConfig.Color sampleConfig.Clock.Color = sampleConfig.Color
} }
@@ -833,7 +656,6 @@ func readConf() (MyConfig, error) {
} }
} }
if sampleConfig.Clock.Separator.Right.Enabled {
if sampleConfig.Clock.Separator.Right.Color == "" { if sampleConfig.Clock.Separator.Right.Color == "" {
sampleConfig.Clock.Separator.Right.Color = sampleConfig.Separator.Right.Color sampleConfig.Clock.Separator.Right.Color = sampleConfig.Separator.Right.Color
} }
@@ -862,7 +684,7 @@ func readConf() (MyConfig, error) {
log.Printf( log.Printf(
"Unable to set sampleConfig.Clock.Separator.Right.FontSize: %s, fallback to %s", "Unable to set sampleConfig.Clock.Separator.Right.FontSize: %s, fallback to %s",
err, err,
sampleConfig.Clock.Separator.Right.FontSize, sampleConfig.Separator.Right.FontSize,
) )
sampleConfig.Clock.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize sampleConfig.Clock.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
@@ -877,7 +699,6 @@ func readConf() (MyConfig, error) {
sampleConfig.Clock.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize sampleConfig.Clock.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
} }
} }
}
// sampleConfig.Clock.LeftClick.Enabled will be false if not set in config // sampleConfig.Clock.LeftClick.Enabled will be false if not set in config
@@ -890,10 +711,8 @@ func readConf() (MyConfig, error) {
if len(sampleConfig.Clock.RightClick.Cmd) == 0 { if len(sampleConfig.Clock.RightClick.Cmd) == 0 {
sampleConfig.Clock.RightClick.Cmd = append(sampleConfig.Clock.RightClick.Cmd, "true") sampleConfig.Clock.RightClick.Cmd = append(sampleConfig.Clock.RightClick.Cmd, "true")
} }
}
// sampleConfig.Battery.Enabled will be false if not set in config // sampleConfig.Battery.Enabled will be false if not set in config
if sampleConfig.Battery.Enabled {
if sampleConfig.Battery.Color == "" { if sampleConfig.Battery.Color == "" {
sampleConfig.Battery.Color = sampleConfig.Color sampleConfig.Battery.Color = sampleConfig.Color
} }
@@ -926,7 +745,6 @@ func readConf() (MyConfig, error) {
// sampleConfig.Battery.ChargeColor.Empty will be empty string if not set // sampleConfig.Battery.ChargeColor.Empty will be empty string if not set
// sampleConfig.Battery.ChargeColor.AlmostFull will be empty string if not set // sampleConfig.Battery.ChargeColor.AlmostFull will be empty string if not set
// sampleConfig.Battery.ChargeColor.AlmostEmpty will be empty string if not set // sampleConfig.Battery.ChargeColor.AlmostEmpty will be empty string if not set
if sampleConfig.Battery.Separator.Left.Enabled {
if sampleConfig.Battery.Separator.Left.Color == "" { if sampleConfig.Battery.Separator.Left.Color == "" {
sampleConfig.Battery.Separator.Left.Color = sampleConfig.Separator.Left.Color sampleConfig.Battery.Separator.Left.Color = sampleConfig.Separator.Left.Color
} }
@@ -970,9 +788,7 @@ func readConf() (MyConfig, error) {
sampleConfig.Battery.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize sampleConfig.Battery.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize
} }
} }
}
if sampleConfig.Battery.Separator.Right.Enabled {
if sampleConfig.Battery.Separator.Right.Color == "" { if sampleConfig.Battery.Separator.Right.Color == "" {
sampleConfig.Battery.Separator.Right.Color = sampleConfig.Separator.Right.Color sampleConfig.Battery.Separator.Right.Color = sampleConfig.Separator.Right.Color
} }
@@ -1016,8 +832,7 @@ func readConf() (MyConfig, error) {
sampleConfig.Battery.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize sampleConfig.Battery.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
} }
} }
}
}
// sampleConfig.CpuTemp.Enabled will be false if not set in config // sampleConfig.CpuTemp.Enabled will be false if not set in config
// No files configured - disable plugin // No files configured - disable plugin
@@ -1025,7 +840,6 @@ func readConf() (MyConfig, error) {
sampleConfig.CPUTemp.Enabled = false sampleConfig.CPUTemp.Enabled = false
} }
if sampleConfig.CPUTemp.Enabled {
if sampleConfig.CPUTemp.Color == "" { if sampleConfig.CPUTemp.Color == "" {
sampleConfig.CPUTemp.Color = sampleConfig.Color sampleConfig.CPUTemp.Color = sampleConfig.Color
} }
@@ -1088,7 +902,6 @@ func readConf() (MyConfig, error) {
} }
} }
if sampleConfig.CPUTemp.Separator.Right.Enabled {
if sampleConfig.CPUTemp.Separator.Right.Color == "" { if sampleConfig.CPUTemp.Separator.Right.Color == "" {
sampleConfig.CPUTemp.Separator.Right.Color = sampleConfig.Separator.Right.Color sampleConfig.CPUTemp.Separator.Right.Color = sampleConfig.Separator.Right.Color
} }
@@ -1130,8 +943,6 @@ func readConf() (MyConfig, error) {
sampleConfig.CPUTemp.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize sampleConfig.CPUTemp.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
} }
} }
}
}
// sampleConfig.Vpn.Enabled will false if not set in config // sampleConfig.Vpn.Enabled will false if not set in config
@@ -1140,7 +951,6 @@ func readConf() (MyConfig, error) {
sampleConfig.Vpn.Enabled = false sampleConfig.Vpn.Enabled = false
} }
if sampleConfig.Vpn.Enabled {
if sampleConfig.Vpn.Color == "" { if sampleConfig.Vpn.Color == "" {
sampleConfig.Vpn.Color = sampleConfig.Color sampleConfig.Vpn.Color = sampleConfig.Color
} }
@@ -1214,7 +1024,6 @@ func readConf() (MyConfig, error) {
} }
} }
if sampleConfig.Vpn.Separator.Right.Enabled {
if sampleConfig.Vpn.Separator.Right.Color == "" { if sampleConfig.Vpn.Separator.Right.Color == "" {
sampleConfig.Vpn.Separator.Right.Color = sampleConfig.Separator.Right.Color sampleConfig.Vpn.Separator.Right.Color = sampleConfig.Separator.Right.Color
} }
@@ -1258,7 +1067,6 @@ func readConf() (MyConfig, error) {
sampleConfig.Vpn.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize sampleConfig.Vpn.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
} }
} }
}
// Disable plugin if value inadequate // Disable plugin if value inadequate
if sampleConfig.Vpn.TCPCheck.Port > 65535 { if sampleConfig.Vpn.TCPCheck.Port > 65535 {
@@ -1285,10 +1093,8 @@ func readConf() (MyConfig, error) {
sampleConfig.Vpn.TCPCheck.Timeout = 3 sampleConfig.Vpn.TCPCheck.Timeout = 3
} }
}
// sampleConfig.SimpleVolumePa.Enabled will false if not set in config // sampleConfig.SimpleVolumePa.Enabled will false if not set in config
if sampleConfig.SimpleVolumePa.Enabled {
if sampleConfig.SimpleVolumePa.Color == "" { if sampleConfig.SimpleVolumePa.Color == "" {
sampleConfig.SimpleVolumePa.Color = sampleConfig.Color sampleConfig.SimpleVolumePa.Color = sampleConfig.Color
} }
@@ -1329,7 +1135,15 @@ func readConf() (MyConfig, error) {
sampleConfig.SimpleVolumePa.WheelDown = 5 sampleConfig.SimpleVolumePa.WheelDown = 5
} }
if sampleConfig.SimpleVolumePa.MaxVolumeLimit == 0 { if sampleConfig.SimpleVolumePa.WheelDown > 100 {
sampleConfig.SimpleVolumePa.WheelDown = 5
}
if sampleConfig.SimpleVolumePa.MaxVolumeLimit <= 0 {
sampleConfig.SimpleVolumePa.MaxVolumeLimit = 100
}
if sampleConfig.SimpleVolumePa.MaxVolumeLimit >= 120 {
sampleConfig.SimpleVolumePa.MaxVolumeLimit = 100 sampleConfig.SimpleVolumePa.MaxVolumeLimit = 100
} }
@@ -1341,7 +1155,6 @@ func readConf() (MyConfig, error) {
sampleConfig.SimpleVolumePa.RightClickCmd = append(sampleConfig.SimpleVolumePa.RightClickCmd, "true") sampleConfig.SimpleVolumePa.RightClickCmd = append(sampleConfig.SimpleVolumePa.RightClickCmd, "true")
} }
if sampleConfig.SimpleVolumePa.Separator.Left.Enabled {
if sampleConfig.SimpleVolumePa.Separator.Left.Color == "" { if sampleConfig.SimpleVolumePa.Separator.Left.Color == "" {
sampleConfig.SimpleVolumePa.Separator.Left.Color = sampleConfig.Separator.Left.Color sampleConfig.SimpleVolumePa.Separator.Left.Color = sampleConfig.Separator.Left.Color
} }
@@ -1385,9 +1198,7 @@ func readConf() (MyConfig, error) {
sampleConfig.SimpleVolumePa.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize sampleConfig.SimpleVolumePa.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize
} }
} }
}
if sampleConfig.SimpleVolumePa.Separator.Right.Enabled {
if sampleConfig.SimpleVolumePa.Separator.Right.Color == "" { if sampleConfig.SimpleVolumePa.Separator.Right.Color == "" {
sampleConfig.SimpleVolumePa.Separator.Right.Color = sampleConfig.Separator.Right.Color sampleConfig.SimpleVolumePa.Separator.Right.Color = sampleConfig.Separator.Right.Color
} }
@@ -1431,8 +1242,6 @@ func readConf() (MyConfig, error) {
sampleConfig.SimpleVolumePa.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize sampleConfig.SimpleVolumePa.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
} }
} }
}
}
// sampleConfig.Cron.Enabled will false if not set in config // sampleConfig.Cron.Enabled will false if not set in config
@@ -1440,18 +1249,16 @@ func readConf() (MyConfig, error) {
sampleConfig.Cron.Enabled = false sampleConfig.Cron.Enabled = false
} }
if sampleConfig.Cron.Enabled {
if sampleConfig.Cron.TimeZone == "" { if sampleConfig.Cron.TimeZone == "" {
sampleConfig.Cron.TimeZone = "GMT+0" sampleConfig.Cron.TimeZone = "GMT+0"
} }
}
// sampleConfig.NetIf.Enabled will false if not set in config // sampleConfig.NetIf.Enabled will false if not set in config
if len(sampleConfig.NetIf.If) == 0 { if len(sampleConfig.NetIf.If) == 0 {
sampleConfig.NetIf.Enabled = false sampleConfig.NetIf.Enabled = false
} }
if sampleConfig.NetIf.Enabled {
if sampleConfig.NetIf.DownColor == "" { if sampleConfig.NetIf.DownColor == "" {
sampleConfig.NetIf.DownColor = "red" sampleConfig.NetIf.DownColor = "red"
} }
@@ -1476,7 +1283,6 @@ func readConf() (MyConfig, error) {
sampleConfig.NetIf.FontSize = sampleConfig.FontSize sampleConfig.NetIf.FontSize = sampleConfig.FontSize
} }
if sampleConfig.NetIf.Separator.Left.Enabled {
if sampleConfig.NetIf.Separator.Left.Color == "" { if sampleConfig.NetIf.Separator.Left.Color == "" {
sampleConfig.NetIf.Separator.Left.Color = sampleConfig.Separator.Left.Color sampleConfig.NetIf.Separator.Left.Color = sampleConfig.Separator.Left.Color
} }
@@ -1519,9 +1325,7 @@ func readConf() (MyConfig, error) {
sampleConfig.NetIf.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize sampleConfig.NetIf.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize
} }
} }
}
if sampleConfig.NetIf.Separator.Right.Enabled {
if sampleConfig.NetIf.Separator.Right.Color == "" { if sampleConfig.NetIf.Separator.Right.Color == "" {
sampleConfig.NetIf.Separator.Right.Color = sampleConfig.Separator.Right.Color sampleConfig.NetIf.Separator.Right.Color = sampleConfig.Separator.Right.Color
} }
@@ -1565,13 +1369,9 @@ func readConf() (MyConfig, error) {
sampleConfig.NetIf.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize sampleConfig.NetIf.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
} }
} }
}
}
// sampleConfig.AppButtons.Enabled will false if not set in config // sampleConfig.AppButtons.Enabled will false if not set in config
if sampleConfig.AppButtons.Enabled {
if sampleConfig.AppButtons.Separator.Left.Enabled {
if sampleConfig.AppButtons.Separator.Left.Color == "" { if sampleConfig.AppButtons.Separator.Left.Color == "" {
sampleConfig.AppButtons.Separator.Left.Color = sampleConfig.Separator.Left.Color sampleConfig.AppButtons.Separator.Left.Color = sampleConfig.Separator.Left.Color
} }
@@ -1600,7 +1400,7 @@ func readConf() (MyConfig, error) {
log.Printf( log.Printf(
"Unable to set sampleConfig.AppButtons.Separator.Left.FontSize: %s, fallback to %s", "Unable to set sampleConfig.AppButtons.Separator.Left.FontSize: %s, fallback to %s",
err, err,
sampleConfig.AppButtons.Separator.Left.FontSize, sampleConfig.Separator.Left.FontSize,
) )
sampleConfig.AppButtons.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize sampleConfig.AppButtons.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize
@@ -1609,15 +1409,13 @@ func readConf() (MyConfig, error) {
if !matched { if !matched {
log.Printf( log.Printf(
"Unable to set sampleConfig.AppButtons.Separator.Left.FontSize, fallback to %s", "Unable to set sampleConfig.AppButtons.Separator.Left.FontSize, fallback to %s",
sampleConfig.AppButtons.Separator.Left.FontSize, sampleConfig.Separator.Left.FontSize,
) )
sampleConfig.AppButtons.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize sampleConfig.AppButtons.Separator.Left.FontSize = sampleConfig.Separator.Left.FontSize
} }
} }
}
if sampleConfig.AppButtons.Separator.Right.Enabled {
if sampleConfig.AppButtons.Separator.Right.Color == "" { if sampleConfig.AppButtons.Separator.Right.Color == "" {
sampleConfig.AppButtons.Separator.Right.Color = sampleConfig.Separator.Right.Color sampleConfig.AppButtons.Separator.Right.Color = sampleConfig.Separator.Right.Color
} }
@@ -1627,7 +1425,7 @@ func readConf() (MyConfig, error) {
} }
if sampleConfig.AppButtons.Separator.Right.Symbol == "" { if sampleConfig.AppButtons.Separator.Right.Symbol == "" {
sampleConfig.AppButtons.Separator.Right.Symbol = "|" sampleConfig.AppButtons.Separator.Right.Symbol = sampleConfig.Separator.Right.Symbol
} }
if sampleConfig.AppButtons.Separator.Right.Font == "" { if sampleConfig.AppButtons.Separator.Right.Font == "" {
@@ -1660,8 +1458,6 @@ func readConf() (MyConfig, error) {
sampleConfig.AppButtons.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize sampleConfig.AppButtons.Separator.Right.FontSize = sampleConfig.Separator.Right.FontSize
} }
} }
}
}
if len(sampleConfig.Apps) == 0 { if len(sampleConfig.Apps) == 0 {
sampleConfig.AppButtons.Enabled = false sampleConfig.AppButtons.Enabled = false