-
Notifications
You must be signed in to change notification settings - Fork 1
/
application.lua
70 lines (56 loc) · 1.86 KB
/
application.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
-- applications
-- deals with assigning applications to the correct space
dofile(zwm.spoonPath.."utilities.lua")
local function application_deactivated(app, name)
-- TODO: Application has been deactivated
end
local function application_activated(app, name)
-- TODO: Application has been deactivated
end
local function application_hidden(app, name)
-- TODO: Application has been hidden
end
local function space(app, space)
return function()
return send_to_space(app, space)
end
end
local function application_launched(app, name)
-- TODO: Application has been launched
local mappings = config["applications"]
local match = match_item(name, mappings)
-- TODO: error checking workspaces
if match ~= nil then
print(name)
local t = hs.timer.doAfter(0.1, space(app, match.f))
-- send_to_space(app, match.f)
end
end
local function application_launching(app, name)
-- TODO: Application has been launching
end
local function application_terminated(app, name)
-- TODO: Application has been terminated
end
local function application_unhidden(app, name)
-- TODO: Application has been unhidden
end
-- calback
local function application_event(name, event, app)
if event == hs.application.watcher.activated then
application_activated(app, name)
elseif event == hs.application.watcher.deactivated then
application_deactivated(app, name)
elseif event == hs.application.watcher.hidden then
application_hidden(app, name)
elseif event == hs.application.watcher.launched then
application_launched(app, name)
elseif event == hs.application.watcher.launching then
application_launching(app, name)
elseif event == hs.application.watcher.terminated then
application_terminated(app, name)
elseif event == hs.application.watcher.unhidden then
application_unhidden(app, name)
end
end
zwm.application_watcher = hs.application.watcher.new(application_event):start()