-
Notifications
You must be signed in to change notification settings - Fork 70
/
multimedia.fnl
51 lines (45 loc) · 933 Bytes
/
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
43
44
45
46
47
48
49
50
51
(fn m-key [key]
"
Simulates pressing a multimedia key on a keyboard
Takes the key string and simulates pressing it for 5 ms then relesing it.
Side effectful.
Returns nil
"
(: (hs.eventtap.event.newSystemKeyEvent (string.upper key) true) :post)
(hs.timer.usleep 5)
(: (hs.eventtap.event.newSystemKeyEvent (string.upper key) false) :post))
(fn play-or-pause
[]
"
Simulate pressing the play\\pause keyboard key
"
(m-key :play))
(fn prev-track
[]
"
Simulate pressing the previous track keyboard key
"
(m-key :previous))
(fn next-track
[]
"
Simulate pressing the next track keyboard key
"
(m-key :next))
(fn volume-up
[]
"
Simulate pressing the volume up key
"
(m-key :sound_up))
(fn volume-down
[]
"
Simulate pressing the volume down key
"
(m-key :sound_down))
{:play-or-pause play-or-pause
:prev-track prev-track
:next-track next-track
:volume-up volume-up
:volume-down volume-down}