forked from agzam/spacehammer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.fnl
72 lines (60 loc) · 1.89 KB
/
core.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(hs.console.clearConsole)
(hs.ipc.cliInstall) ; ensure CLI installed
;;;;;;;;;;;;;;
;; defaults ;;
;;;;;;;;;;;;;;
(set hs.hints.style :vimperator)
(set hs.hints.showTitleThresh 4)
(set hs.hints.titleMaxSize 10)
(set hs.hints.fontSize 30)
(set hs.window.animationDuration 0.2)
(global alert hs.alert.show)
(global log (fn [s] (hs.alert.show (hs.inspect s) 5)))
(global fw hs.window.focusedWindow)
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; auto reload config ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
(global
config-file-pathwatcher
(hs.pathwatcher.new
hs.configdir
(fn [files]
(let [u hs.fnutils
fnl-file-change? (u.some
files
(fn [p]
(when (not (string.match p ".#")) ;; ignore emacs temp files
(let [ext (u.split p "%p")]
(or (u.contains ext "fnl")
(u.contains ext "lua"))))))]
(when fnl-file-change? (hs.reload))))))
(: config-file-pathwatcher :start)
;;;;;;;;;;;;
;; modals ;;
;;;;;;;;;;;;
(local modal (require :modal))
(each [_ n (pairs [:windows
:apps
:multimedia
:emacs
:chrome
:grammarly])]
(let [module (require n)]
(when module.add-state
(module.add-state modal))
(when module.add-app-specific
(module.add-app-specific))))
(let [state-machine (modal.create-machine)]
(: state-machine :toMain))
(require :keybindings)
;; toggle hs.console with Ctrl+Cmd+~
(hs.hotkey.bind
[:ctrl :cmd] "`" nil
(fn []
(let [console (hs.console.hswindow)]
(when console
(if (= console (hs.window.focusedWindow))
(-> console (: :application) (: :hide))
(-> console (: :raise) (: :focus)))))))
;; disable annoying Cmd+M for minimizing windows
(hs.hotkey.bind [:cmd] :m nil (fn [] nil))