-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmixer.lua
82 lines (72 loc) · 2.16 KB
/
mixer.lua
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
local mixer = {}
local log = hs.logger.new('mixer', 'debug')
mixer.hotkeys = {}
mixer.colorPicker = dofile(hs.spoons.resourcePath('color_picker.lua'))
-----------
-- setup --
-----------
function mixer:bindHotkeys(maps)
table.insert(mixer.hotkeys, mixer:color(maps))
table.insert(mixer.hotkeys, mixer:createMixChannel(maps))
table.insert(mixer.hotkeys, mixer:resetChannelSettings(maps))
end
function mixer:activate(app)
for _, v in pairs(mixer.hotkeys) do v:enable() end
mixer.app = app
log.d('mixer activated')
end
function mixer:deactivate()
for _, v in pairs(mixer.hotkeys) do v:disable() end
log.d('mixer deactivated')
end
--------------
-- keybinds --
--------------
-- mixer:color(m)
-- Method
-- Activates a colorPicker (hs.chooser) with available channel colors
-- The selected color is then applied to the selected channels
--
-- Parameters:
-- * m - A table of hotkey mappings
--
-- Returns:
-- * An hs.hotkey object, to be addded to this module's hotkeys table
function mixer:color(m)
return hs.hotkey.new(m.color[1], m.color[2], function()
mixer.colorPicker:setup(mixer.app, 'Channel color')
mixer.colorPicker:show()
log.d('showing mixer channel color picker')
end)
end
-- mixer:createMixChannel(m)
-- Method
-- Creates a new mixer channel
--
-- Parameters:
-- * m - A table of hotkey mappings
--
-- Returns:
-- * An hs.hotkey object, to be addded to this module's hotkeys table
function mixer:createMixChannel(m)
return hs.hotkey.new(m.createMixChannel[1], m.createMixChannel[2], function()
mixer.app:selectMenuItem({ 'Create', 'Create Mix Channel' })
log.d('created mix channel')
end)
end
-- mixer:resetAllChannelSettings(m)
-- Method
-- Resets the channel settings to default
--
-- Parameters:
-- * m - A table of hotkey mappings
--
-- Returns:
-- * An hs.hotkey object, to be addded to this module's hotkeys table
function mixer:resetChannelSettings(m)
return hs.hotkey.new(m.resetAllChannelSettings[1], m.resetAllChannelSettings[2], function()
mixer.app:selectMenuItem({ 'Edit', 'Reset All Channel Settings' })
log.d('reset all channel settings')
end)
end
return mixer