diff --git a/config.go b/config.go index a284137..a081177 100644 --- a/config.go +++ b/config.go @@ -4,6 +4,7 @@ import ( "fmt" "os" + "github.com/eeeXun/gtt/internal/style" "github.com/eeeXun/gtt/internal/translate" config "github.com/spf13/viper" ) @@ -15,7 +16,7 @@ func configInit() { defaultConfig = map[string]interface{}{ "hide_below": false, "transparent": false, - "theme": "Gruvbox", + "theme": "gruvbox", "source.border_color": "red", "destination.border_color": "blue", "source.language.apertiumtranslate": "English", @@ -42,7 +43,7 @@ func configInit() { } config.AddConfigPath("$HOME/.config/gtt") - // Create config file if not exists + // Create config file if it does not exist // Otherwise check if config value is missing if err := config.ReadInConfig(); err != nil { for key, value := range defaultConfig { @@ -60,6 +61,11 @@ func configInit() { missing = true } } + // Set to default theme if theme in config does not exist + if IndexOf(config.GetString("theme"), style.AllTheme) < 0 { + config.Set("theme", defaultConfig["theme"]) + missing = true + } if missing { config.WriteConfig() } diff --git a/internal/style/color.go b/internal/style/color.go index a90eca4..29069c4 100644 --- a/internal/style/color.go +++ b/internal/style/color.go @@ -5,10 +5,10 @@ import ( ) var ( - AllTheme = []string{"Gruvbox", "Nord"} + AllTheme = []string{"gruvbox", "nord"} Palette = []string{"red", "green", "yellow", "blue", "purple", "cyan", "orange"} themes = map[string]map[string]tcell.Color{ - "Gruvbox": { + "gruvbox": { "bg": tcell.NewHexColor(0x282828), "fg": tcell.NewHexColor(0xebdbb2), "gray": tcell.NewHexColor(0x665c54), @@ -20,7 +20,7 @@ var ( "cyan": tcell.NewHexColor(0x8ec07c), "orange": tcell.NewHexColor(0xfe8019), }, - "Nord": { + "nord": { "bg": tcell.NewHexColor(0x3b4252), "fg": tcell.NewHexColor(0xeceff4), "gray": tcell.NewHexColor(0x4c566a),