Skip to content

Commit

Permalink
added checkmark in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
frese committed Jul 10, 2020
1 parent 5274286 commit 2c869c5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ var menuItems = []trayhost.MenuItem{
},
}

var menuItemsCopy = []trayhost.MenuItem{}

func appInit() {

// On macOS, when you run an app bundle, the working directory of the executed process
Expand All @@ -61,16 +63,43 @@ func appInit() {
log.Fatalln(err)
}

// Set initial checkmark for autostart
if existsLaunchConf() {
for i, m := range menuItems {
if m.Title == "Startup on login" {
menuItems[i].Title = "√ Startup on login"
}
}
}
for _, m := range menuItems {
menuItemsCopy = append(menuItemsCopy, m)
}

trayhost.Initialize("Pagerduty Notifier", iconData, menuItems)
}

func toggleStartup() {
if existsLaunchConf() {
deleteLaunchConf()
appNotify("Pagerduty Notifier", "Removed from Launch configuration", "", nil, 10*time.Second)

for i, m := range menuItemsCopy {
if m.Title == "√ Startup on login" {
menuItemsCopy[i].Title = "Startup on login"
}
}
trayhost.UpdateMenu(menuItemsCopy)

} else {
writeLaunchConf()
appNotify("Pagerduty Notifier", "Added to launch configuration", "", nil, 10*time.Second)

for i, m := range menuItemsCopy {
if m.Title == "Startup on login" {
menuItemsCopy[i].Title = "√ Startup on login"
}
}
trayhost.UpdateMenu(menuItemsCopy)
}
}

Expand Down

0 comments on commit 2c869c5

Please sign in to comment.