Skip to content

Commit 5e28692

Browse files
authored
feat: add notification center hints (configurable) (#49)
1 parent 3ae3a59 commit 5e28692

5 files changed

Lines changed: 45 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,13 @@ ctrl - s : scroll
319319

320320
Read more about [CLI Usage](#%EF%B8%8F-cli-usage).
321321

322-
#### Enable Menu Bar and Dock Hints
322+
#### Enable Menu Bar Dock and Notification Center Hints
323323

324324
```toml
325325
[general]
326326
include_menubar_hints = true
327327
include_dock_hints = true # Also includes Mission Control
328+
include_nc_hints = true # Notification popups
328329
```
329330

330331
#### Restore cursor after click action

cmd/govim/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,16 @@ func (a *App) activateHintMode(withActions bool) {
423423
}
424424
}
425425

426+
// Optionally include Notification Center elements
427+
if a.config.General.IncludeNCHints {
428+
if ncElems, derr := accessibility.GetNCClickableElements(); derr == nil {
429+
elements = append(elements, ncElems...)
430+
a.logger.Debug("Included nc elements", zap.Int("count", len(ncElems)))
431+
} else {
432+
a.logger.Warn("Failed to get nc elements", zap.Error(derr))
433+
}
434+
}
435+
426436
if len(elements) == 0 {
427437
a.logger.Warn("No clickable elements found")
428438
return

configs/default-config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ excluded_apps = []
2828
include_menubar_hints = false
2929
# Show hints on the Dock (includes mission control)
3030
include_dock_hints = false
31+
# Show hints on the Notification Center
32+
include_nc_hints = false
3133

3234
# Restore cursor position after action
3335
# Restore cursor position after left click

internal/accessibility/query.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,32 @@ func GetDockClickableElements() ([]*TreeNode, error) {
189189
}
190190
return tree.FindClickableElements(), nil
191191
}
192+
193+
// GetNCClickableElements returns clickable elements from the Notification Center
194+
func GetNCClickableElements() ([]*TreeNode, error) {
195+
nc := GetApplicationByBundleID("com.apple.notificationcenterui")
196+
if nc == nil {
197+
return []*TreeNode{}, nil
198+
}
199+
defer nc.Release()
200+
201+
opts := DefaultTreeOptions()
202+
opts.IncludeOutOfBounds = true
203+
opts.CheckOcclusion = false
204+
opts.MaxDepth = 8
205+
opts.FilterFunc = func(info *ElementInfo) bool {
206+
if info.Size.X < 6 || info.Size.Y < 6 {
207+
return false
208+
}
209+
return true
210+
}
211+
212+
tree, err := BuildTree(nc, opts)
213+
if err != nil {
214+
return nil, err
215+
}
216+
if tree == nil {
217+
return []*TreeNode{}, nil
218+
}
219+
return tree.FindClickableElements(), nil
220+
}

internal/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type GeneralConfig struct {
2525
ExcludedApps []string `toml:"excluded_apps"`
2626
IncludeMenubarHints bool `toml:"include_menubar_hints"`
2727
IncludeDockHints bool `toml:"include_dock_hints"`
28+
IncludeNCHints bool `toml:"include_nc_hints"`
2829
RestorePosAfterLeftClick bool `toml:"restore_pos_after_left_click"`
2930
RestorePosAfterRightClick bool `toml:"restore_pos_after_right_click"`
3031
RestorePosAfterMiddleClick bool `toml:"restore_pos_after_middle_click"`
@@ -108,6 +109,7 @@ func DefaultConfig() *Config {
108109
ExcludedApps: []string{},
109110
IncludeMenubarHints: false,
110111
IncludeDockHints: false,
112+
IncludeNCHints: false,
111113
RestorePosAfterLeftClick: false,
112114
RestorePosAfterRightClick: false,
113115
RestorePosAfterMiddleClick: false,

0 commit comments

Comments
 (0)