diff --git a/cmd/awl-tray/tray.go b/cmd/awl-tray/tray.go index 252eae97..b8c2ceef 100644 --- a/cmd/awl-tray/tray.go +++ b/cmd/awl-tray/tray.go @@ -5,6 +5,7 @@ import ( _ "embed" "fmt" "image" + "path/filepath" "runtime" "slices" "sort" @@ -130,6 +131,14 @@ func initTray() { } }() + advancedMenu := systray.AddMenuItem("Advanced", "") + editConfigMenu := advancedMenu.AddSubMenuItem("Edit raw config", "Open config file in default editor") + go func() { + for range editConfigMenu.ClickedCh { + onClickEditRawConfig() + } + }() + systray.AddSeparator() mQuit := systray.AddMenuItem("Quit", "Quit the whole app") go func() { @@ -300,6 +309,23 @@ func refreshProxySubmenus() { } } +func onClickEditRawConfig() { + if app != nil { + ok := showQuestionDialog("Anywherelan", "Server is currently running.\nYou need to stop the server before editing the config,\notherwise your changes will be overwritten.\n\nStop the server now?", "Stop server") + if !ok { + return + } + StopServer() + } + + configPath := filepath.Join(config.CalcAppDataDir(), config.AppConfigFilename) + err := openURL(configPath) + if err != nil { + logger.Errorf("failed to open config file %s: %v", configPath, err) + showErrorDialog("Anywherelan error", fmt.Sprintf("Failed to open config file %s: %v", configPath, err)) + } +} + func onClickUpdateMenu() error { updateMenu.SetTitle("Checking...") updateMenu.Disable()