-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultimedia.fnl
More file actions
39 lines (32 loc) · 1001 Bytes
/
multimedia.fnl
File metadata and controls
39 lines (32 loc) · 1001 Bytes
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
(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))
(fn mute []
"Simulate pressing the mute key"
(m-key :mute))
{:play-or-pause play-or-pause
:prev-track prev-track
:next-track next-track
:volume-up volume-up
:volume-down volume-down
:mute mute}