Skip to content

Commit f480e35

Browse files
umbynoscmaglie
authored andcommitted
add a menu in the tray menu to open the config file fix #734
1 parent 3b8b935 commit f480e35

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

main.go

+1
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ func loop() {
255255
if err != nil {
256256
log.Panicf("cannot parse arguments: %s", err)
257257
}
258+
Systray.SetCurrentConfigFile(configPath)
258259

259260
// Parse additional ini config if defined
260261
if len(*additionalConfig) > 0 {

systray/systray.go

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"os/exec"
2222
"strings"
2323

24+
"github.com/arduino/go-paths-helper"
2425
log "github.com/sirupsen/logrus"
2526
)
2627

@@ -38,6 +39,8 @@ type Systray struct {
3839
ConfigDir *paths.Path
3940
// The path of the exe (only used in update)
4041
path string
42+
// The path of the configuration file
43+
currentConfigFilePath *paths.Path
4144
}
4245

4346
// Restart restarts the program
@@ -94,3 +97,9 @@ func (s *Systray) Update(path string) {
9497
s.path = path
9598
s.Restart()
9699
}
100+
101+
// SetCurrentConfigFile allows to specify the path of the configuration file the agent
102+
// is using. The tray menu with this info can display an "open config file" option.
103+
func (s *Systray) SetCurrentConfigFile(configPath *paths.Path) {
104+
s.currentConfigFilePath = configPath
105+
}

systray/systray_real.go

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func (s *Systray) start() {
5757
// Add links
5858
mURL := systray.AddMenuItem("Go to Arduino Create", "Arduino Create")
5959
mDebug := systray.AddMenuItem("Open Debug Console", "Debug console")
60+
mConfig := systray.AddMenuItem("Open Configuration", "Config File")
6061

6162
// Remove crash-reports
6263
mRmCrashes := systray.AddMenuItem("Remove crash reports", "")
@@ -78,6 +79,8 @@ func (s *Systray) start() {
7879
_ = open.Start("https://create.arduino.cc")
7980
case <-mDebug.ClickedCh:
8081
_ = open.Start(s.DebugURL())
82+
case <-mConfig.ClickedCh:
83+
_ = open.Start(s.currentConfigFilePath.String())
8184
case <-mRmCrashes.ClickedCh:
8285
s.RemoveCrashes()
8386
s.updateMenuItem(mRmCrashes, s.CrashesIsEmpty())

0 commit comments

Comments
 (0)