diff options
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 34 |
1 files changed, 29 insertions, 5 deletions
@@ -107,11 +107,15 @@ func (conf *Config) Load() error { } conf.PercpuLoad = bv case tempscale: - iv, err := strconv.Atoi(kv[1]) - if err != nil { - return err + switch kv[1] { + case "C": + conf.TempScale = 'C' + case "F": + conf.TempScale = 'F' + default: + conf.TempScale = 'C' + return fmt.Errorf("invalid TempScale value %s", kv[1]) } - conf.TempScale = widgets.TempScale(iv) case statusbar: bv, err := strconv.ParseBool(kv[1]) if err != nil { @@ -159,19 +163,39 @@ func (c *Config) Write() (string, error) { func marshal(c *Config) []byte { buff := bytes.NewBuffer(nil) + fmt.Fprintln(buff, "# Scale graphs to this level; 7 is the default, 2 is zoomed out.") fmt.Fprintf(buff, "%s=%d\n", graphhorizontalscale, c.GraphHorizontalScale) + fmt.Fprintln(buff, "# If true, start the UI with the help visible") fmt.Fprintf(buff, "%s=%t\n", helpvisible, c.HelpVisible) + fmt.Fprintln(buff, "# The color scheme to use. See `--list colorschemes`") fmt.Fprintf(buff, "%s=%s\n", colorscheme, c.Colorscheme.Name) + fmt.Fprintln(buff, "# How frequently to update the UI, in nanoseconds") fmt.Fprintf(buff, "%s=%d\n", updateinterval, c.UpdateInterval) + fmt.Fprintln(buff, "# If true, show the average CPU load") fmt.Fprintf(buff, "%s=%t\n", averagecpu, c.AverageLoad) + fmt.Fprintln(buff, "# If true, show load per CPU") fmt.Fprintf(buff, "%s=%t\n", percpuload, c.PercpuLoad) - fmt.Fprintf(buff, "%s=%d\n", tempscale, c.TempScale) + fmt.Fprintln(buff, "# Temperature units. C for Celcius, F for Fahrenheit") + fmt.Fprintf(buff, "%s=%c\n", tempscale, c.TempScale) + fmt.Fprintln(buff, "# If true, display a status bar") fmt.Fprintf(buff, "%s=%t\n", statusbar, c.Statusbar) + fmt.Fprintln(buff, "# The network interface to monitor") fmt.Fprintf(buff, "%s=%s\n", netinterface, c.NetInterface) + fmt.Fprintln(buff, "# A layout name. See `--list layouts`") fmt.Fprintf(buff, "%s=%s\n", layout, c.Layout) + fmt.Fprintln(buff, "# The maximum log file size, in bytes") fmt.Fprintf(buff, "%s=%d\n", maxlogsize, c.MaxLogSize) + fmt.Fprintln(buff, "# If set, export data as Promethius metrics on the interface:port.\n# E.g., `:8080` (colon is required, interface is not)") + if c.ExportPort == "" { + fmt.Fprint(buff, "#") + } fmt.Fprintf(buff, "%s=%s\n", export, c.ExportPort) + fmt.Fprintln(buff, "# Display network IO in mpbs if true") fmt.Fprintf(buff, "%s=%t\n", mbps, c.Mbps) + fmt.Fprintln(buff, "# A list of enabled temp sensors. See `--list devices`") + if len(c.Temps) == 0 { + fmt.Fprint(buff, "#") + } fmt.Fprintf(buff, "%s=%s\n", temperatures, strings.Join(c.Temps, ",")) return buff.Bytes() } |