-
Notifications
You must be signed in to change notification settings - Fork 70
/
slack.fnl
105 lines (80 loc) · 1.88 KB
/
slack.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
(local windows (require :windows))
"
Slack functions to make complex or less accessible features more vim like!
"
;; Utils
(fn scroll-to-bottom
[]
(windows.set-mouse-cursor-at :Slack)
(hs.eventtap.scrollWheel [0 -20000] {}))
(fn add-reaction
[]
(hs.eventtap.keyStroke [:cmd :shift] "\\"))
(fn prev-element
[]
(hs.eventtap.keyStroke [:shift] :f6))
(fn next-element
[]
(hs.eventtap.keyStroke nil :f6))
(fn thread
[]
"
Start a thread on the last message. It doesn't always work, because of
stupid Slack App inconsistency with TabIndexes
"
(hs.eventtap.keyStroke [:shift] :f6)
(hs.eventtap.keyStroke [] :right)
(hs.eventtap.keyStroke [] :space))
(fn quick-switcher
[]
(windows.activate-app "/Applications/Slack.app")
(let [app (hs.application.find :Slack)]
(when app
(hs.eventtap.keyStroke [:cmd] :t)
(: app :unhide))))
;; scroll to prev/next day
(fn prev-day
[]
(hs.eventtap.keyStroke [:shift] :pageup))
(fn next-day
[]
(hs.eventtap.keyStroke [:shift] :pagedown))
;; Scrolling functions
(fn scroll-slack
[dir]
(windows.set-mouse-cursor-at :Slack)
(hs.eventtap.scrollWheel [0 dir] {}))
(fn scroll-up
[]
(scroll-slack 3))
(fn scroll-down
[]
(scroll-slack -3))
;; History
(fn prev-history
[]
(hs.eventtap.keyStroke [:cmd] "["))
(fn next-history
[]
(hs.eventtap.keyStroke [:cmd] "]"))
;; Arrow keys
(fn up
[]
(hs.eventtap.keyStroke nil :up))
(fn down
[]
(hs.eventtap.keyStroke nil :down))
{:add-reaction add-reaction
:down down
:next-day next-day
:next-element next-element
:next-history next-history
:prev-day prev-day
:prev-element prev-element
:prev-history prev-history
:quick-switcher quick-switcher
:scroll-down scroll-down
:scroll-to-bottom scroll-to-bottom
:scroll-up scroll-up
:thread thread
:up up}