diff --git a/config.go b/config.go index 9015438..547736d 100644 --- a/config.go +++ b/config.go @@ -18,6 +18,7 @@ func configInit() { } config.AddConfigPath("$HOME/.config/gtt") + // create config file if not exists if err := config.ReadInConfig(); err != nil { config.Set("transparent", false) config.Set("theme", "Gruvbox") @@ -28,4 +29,10 @@ func configInit() { } config.SafeWriteConfig(); } + + // setup + theme = config.GetString("theme") + transparent = config.GetBool("transparent") + translator.src_lang = config.GetString("source_language") + translator.dst_lang = config.GetString("destination_language") } diff --git a/main.go b/main.go index 7fae2a2..c7962c5 100644 --- a/main.go +++ b/main.go @@ -18,13 +18,11 @@ var ( pages = tview.NewPages() window Window // config - theme string = "Gruvbox" - transparent bool = true + theme string + transparent bool ) func main() { - translator.src_lang = "English" - translator.dst_lang = "Chinese (Traditional)" // result, _ := translator.Translate("Hello world\nApple\nbumper") // fmt.Println(result) configInit()