Skip to content

Add "Open config file" menu item #763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add a menu in the tray menu to open the config file fix #734
  • Loading branch information
umbynos authored and cmaglie committed Feb 10, 2023
commit f480e35a95184e59e80db9936ca9b7318b39bbdd
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ func loop() {
if err != nil {
log.Panicf("cannot parse arguments: %s", err)
}
Systray.SetCurrentConfigFile(configPath)

// Parse additional ini config if defined
if len(*additionalConfig) > 0 {
Expand Down
9 changes: 9 additions & 0 deletions systray/systray.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os/exec"
"strings"

"github.com/arduino/go-paths-helper"
log "github.com/sirupsen/logrus"
)

Expand All @@ -38,6 +39,8 @@ type Systray struct {
ConfigDir *paths.Path
// The path of the exe (only used in update)
path string
// The path of the configuration file
currentConfigFilePath *paths.Path
}

// Restart restarts the program
Expand Down Expand Up @@ -94,3 +97,9 @@ func (s *Systray) Update(path string) {
s.path = path
s.Restart()
}

// SetCurrentConfigFile allows to specify the path of the configuration file the agent
// is using. The tray menu with this info can display an "open config file" option.
func (s *Systray) SetCurrentConfigFile(configPath *paths.Path) {
s.currentConfigFilePath = configPath
}
3 changes: 3 additions & 0 deletions systray/systray_real.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (s *Systray) start() {
// Add links
mURL := systray.AddMenuItem("Go to Arduino Create", "Arduino Create")
mDebug := systray.AddMenuItem("Open Debug Console", "Debug console")
mConfig := systray.AddMenuItem("Open Configuration", "Config File")

// Remove crash-reports
mRmCrashes := systray.AddMenuItem("Remove crash reports", "")
Expand All @@ -78,6 +79,8 @@ func (s *Systray) start() {
_ = open.Start("https://create.arduino.cc")
case <-mDebug.ClickedCh:
_ = open.Start(s.DebugURL())
case <-mConfig.ClickedCh:
_ = open.Start(s.currentConfigFilePath.String())
case <-mRmCrashes.ClickedCh:
s.RemoveCrashes()
s.updateMenuItem(mRmCrashes, s.CrashesIsEmpty())
Expand Down