forked from agzam/spacehammer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultimedia.fnl
42 lines (35 loc) · 1.32 KB
/
multimedia.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
(local music-app "Google Play Music Desktop Player")
(fn m-key [key]
(: (hs.eventtap.event.newSystemKeyEvent (string.upper key) true) :post)
(hs.timer.usleep 5)
(: (hs.eventtap.event.newSystemKeyEvent (string.upper key) false) :post))
(fn bind [hotkeyMmodal fsm]
(: hotkeyMmodal :bind nil :a
(fn []
(hs.application.launchOrFocus music-app)
(: fsm :toIdle)))
(: hotkeyMmodal :bind nil :h (fn [] (m-key :previous) (: fsm :toIdle)))
(: hotkeyMmodal :bind nil :l (fn [] (m-key :next) (: fsm :toIdle)))
(let [sup (fn [] (m-key :sound_up))]
(: hotkeyMmodal :bind nil :k sup nil sup))
(let [sdn (fn [] (m-key :sound_down))]
(: hotkeyMmodal :bind nil :j sdn nil sdn))
(let [pl (fn []
(m-key :play)
(: fsm :toIdle))]
(: hotkeyMmodal :bind nil :s pl)))
(fn add-state [modal]
(modal.add-state
:media
{:from :*
:init (fn [self fsm]
(set self.hotkeyModal (hs.hotkey.modal.new))
(modal.display-modal-text "h \t previous track\nl \t next track\nk \t volume up\nj \t volume down\ns \t play/pause\na \t launch player")
(modal.bind
self
[:cmd] :space
(fn [] (: fsm :toMain)))
(bind self.hotkeyModal fsm)
(: self.hotkeyModal :enter))}))
{:add-state add-state
:music-app music-app}