-
Notifications
You must be signed in to change notification settings - Fork 1
/
bookmarks.go
47 lines (37 loc) · 827 Bytes
/
bookmarks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"os"
"path/filepath"
)
const BookmarkPListPath = "/Library/Application Support/Orion/Defaults/favourites.plist"
func searchBookmarks() error {
showUpdateStatus()
home, err := os.UserHomeDir()
if err != nil {
return err
}
plistPath := filepath.Join(home, BookmarkPListPath)
b, err := ReadPlist[BookmarkList](plistPath)
if err != nil {
return err
}
for id, item := range *b {
if item.Type != "bookmark" {
continue
}
match := fmt.Sprintf("%s %s", item.Title, item.Url)
if item.Keyword != "" {
match = fmt.Sprintf("%s %s", item.Keyword, match)
}
wf.NewItem(item.Title).
Valid(true).
UID(id).
Subtitle(item.Url).
Match(match).
Arg(item.Url)
}
wf.WarnEmpty("No matching bookmarks found", "Try another search?")
wf.SendFeedback()
return nil
}