Skip to content

Commit ef254dd

Browse files
committed
cmd/awl-tray: add submenu to edit config file in raw text
1 parent df5c8e4 commit ef254dd

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

cmd/awl-tray/tray.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
_ "embed"
66
"fmt"
77
"image"
8+
"path/filepath"
89
"runtime"
910
"slices"
1011
"sort"
@@ -130,6 +131,14 @@ func initTray() {
130131
}
131132
}()
132133

134+
advancedMenu := systray.AddMenuItem("Advanced", "")
135+
editConfigMenu := advancedMenu.AddSubMenuItem("Edit raw config", "Open config file in default editor")
136+
go func() {
137+
for range editConfigMenu.ClickedCh {
138+
onClickEditRawConfig()
139+
}
140+
}()
141+
133142
systray.AddSeparator()
134143
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
135144
go func() {
@@ -300,6 +309,23 @@ func refreshProxySubmenus() {
300309
}
301310
}
302311

312+
func onClickEditRawConfig() {
313+
if app != nil {
314+
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")
315+
if !ok {
316+
return
317+
}
318+
StopServer()
319+
}
320+
321+
configPath := filepath.Join(config.CalcAppDataDir(), config.AppConfigFilename)
322+
err := openURL(configPath)
323+
if err != nil {
324+
logger.Errorf("failed to open config file %s: %v", configPath, err)
325+
showErrorDialog("Anywherelan error", fmt.Sprintf("Failed to open config file %s: %v", configPath, err))
326+
}
327+
}
328+
303329
func onClickUpdateMenu() error {
304330
updateMenu.SetTitle("Checking...")
305331
updateMenu.Disable()

0 commit comments

Comments
 (0)