Skip to content

Commit 5c121db

Browse files
authored
feat: add more actions to systray menu for Neru (#76)
1 parent a76b29f commit 5c121db

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ This is an intentional design choice to keep the project lean, maintainable, and
6969
- Cant actually make scroll works in Electron apps, what is the best approach? There are tons of random `AXGroup` where some is scrollable and some is not...
7070
- Sort of working in Mision Control, but it still shows hints from the frontmost app. How can we know that we are in mission control and ignore the frontmost app?
7171
- Research if there's a good way to implemet visual hint mode where we can select text? Doing this with accessibility seems a little hard and vague
72-
- Add more actions to the menubar like `status`, `stop`, `start`, `current version`
7372
- Test suites, but am lazy for it
7473
- Implements launch agent with `start-service` and `stop-service`? Though I am fine just doing it in my nix config directly
7574
- Better app icon and menubar icon

cmd/neru/main.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,11 +1162,43 @@ func onReady() {
11621162
systray.SetTitle("⌨️")
11631163
systray.SetTooltip("Neru - Keyboard Navigation")
11641164

1165+
// Status submenu for version
1166+
mVersion := systray.AddMenuItem(fmt.Sprintf("Version %s", cli.Version), "Show version")
1167+
mVersion.Disable()
1168+
1169+
// Status toggle
1170+
mStatus := systray.AddMenuItem("Status: Running", "Show current status")
1171+
mStatus.Disable()
1172+
1173+
// Control actions
1174+
systray.AddSeparator()
1175+
mToggle := systray.AddMenuItem("Stop", "Pause/Resume Neru functionality")
1176+
1177+
// Quit option
1178+
systray.AddSeparator()
11651179
mQuit := systray.AddMenuItem("Quit Neru", "Exit the application")
11661180

1181+
// Handle clicks in a separate goroutine
11671182
go func() {
1168-
<-mQuit.ClickedCh
1169-
systray.Quit()
1183+
for {
1184+
select {
1185+
case <-mToggle.ClickedCh:
1186+
if globalApp != nil {
1187+
if globalApp.enabled {
1188+
globalApp.enabled = false
1189+
mStatus.SetTitle("Status: Paused")
1190+
mToggle.SetTitle("Start")
1191+
} else {
1192+
globalApp.enabled = true
1193+
mStatus.SetTitle("Status: Running")
1194+
mToggle.SetTitle("Stop")
1195+
}
1196+
}
1197+
case <-mQuit.ClickedCh:
1198+
systray.Quit()
1199+
return
1200+
}
1201+
}
11701202
}()
11711203
}
11721204

0 commit comments

Comments
 (0)