-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
62 lines (49 loc) · 1.63 KB
/
init.lua
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
local obj = {}
obj.__index = obj
-- Metadata
obj.name = "Chrome Bookmarks"
obj.version = "1.0"
obj.author = "Pavel Makhov"
obj.homepage = "https://fork-my-spoons.github.io/spoons/bookmarks/"
obj.license = "MIT - https://opensource.org/licenses/MIT"
obj.indicator = nil
obj.iconPath = hs.spoons.resourcePath("icons")
obj.timer = nil
obj.refreshTimer = nil
obj.notificationType = nil
obj.menu = {}
local function build(menu, n)
for _, node in ipairs(n.children) do
if node.type == 'url' then
table.insert(menu, {
image = hs.image.imageFromPath(obj.iconPath .. '/external-link.png'):setSize({w=16,h=16}):template(true),
title = node.name,
fn = function() os.execute('open ' .. node.url) end
})
elseif node.type == 'folder' then
table.insert(menu, {
image = hs.image.imageFromPath(obj.iconPath .. '/folder.png'):setSize({w=16,h=16}):template(true),
title = node.name,
menu = build({}, node)
})
end
end
return menu
end
function obj:buildMenu()
local b = hs.json.read(os.getenv("HOME") .. '/Library/Application Support/Google/Chrome/Default/Bookmarks')
local menu = {}
return build(menu, b.roots.bookmark_bar)
end
function obj:aaa()
return obj.menu
end
function obj:init()
self.indicator = hs.menubar.new()
self.indicator:setIcon(hs.image.imageFromPath(self.iconPath .. '/bookmark.png'):setSize({w=16,h=16}), true)
self.indicator:setMenu(self.buildMenu)
end
function obj:setup(args)
self.notificationType = args.notificationType or 'alert'
end
return obj