forked from agzam/spacehammer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchrome.fnl
55 lines (42 loc) · 1.61 KB
/
chrome.fnl
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
;; setting conflicting Cmd+L (jump to address bar) keybinding to Cmd+Shift+L
(fn cmd-sl []
(hs.hotkey.new
[:cmd :shift] :l
(fn []
(let [app (: (hs.window.focusedWindow) :application)]
(when app
(: app :selectMenuItem ["File" "Open Location…"]))))))
(fn browser-modal [self fsm]
(let [modal (require :modal)
emacs (require :emacs)]
(: self :bind nil "'"
(fn []
(emacs.edit-with-emacs)
(: (modal.machine) :toIdle)))
(: self :bind nil :escape (fn [] (: (modal.machine) :toIdle)))
(fn self.entered []
(modal.display-modal-text "' \tedit-with-emacs\n"))))
(fn add-app-specific []
(let [keybindings (require :keybindings)]
(keybindings.add-app-specific
"Google Chrome"
{:activated
(fn []
(keybindings.activate-app-key "Google Chrome" (cmd-sl))
(each [h hk (pairs (keybindings.simple-tab-switching))]
(keybindings.activate-app-key "Google Chrome" hk)))
:deactivated (fn [] (keybindings.deactivate-app-keys "Google Chrome"))
:app-local-modal browser-modal})
;; Since Chrome and Brave Browser are very similar, for now related
;; functions are placed together
(keybindings.add-app-specific
"Brave Browser"
{:activated
(fn []
(keybindings.activate-app-key "Brave Browser" (cmd-sl))
(each [h hk (pairs (keybindings.simple-tab-switching))]
(keybindings.activate-app-key "Brave Browser" hk)))
:deactivated
(fn [] (keybindings.deactivate-app-keys "Brave Browser"))
:app-local-modal browser-modal})))
{:add-app-specific add-app-specific}