-
Notifications
You must be signed in to change notification settings - Fork 0
/
chooser.lua
33 lines (33 loc) · 1.01 KB
/
chooser.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
-- Spotlight-like Google search
chooser = hs.chooser.new(function(args)
os.execute(string.format("open %s", args.subText))
end)
chooser:queryChangedCallback(function(query)
query = query:gsub(" ", "+")
chooser:choices({
{
["text"] = string.format("Search Google for `%s`", query),
["subText"] = string.format("https://www.google.ca/#q=%s", query),
},
{
["text"] = string.format("Search Google Finance for `%s`", query),
["subText"] = string.format("https://www.google.ca/finance?q=%s", query),
},
{
["text"] = string.format("Open subreddit `%s`", query),
["subText"] = string.format("https://www.reddit.com/r/%s", query),
},
})
end)
chooser:bgDark(true)
chooser:rows(3)
lastFocus = nil
hs.hotkey.bind({"ctrl"}, "space", function()
if chooser:isVisible() then
chooser:hide()
lastFocus:focus()
else
lastFocus = hs.window.focusedWindow()
chooser:show()
end
end)