hs: remove onInit, use onLaunched

This commit is contained in:
Henrik Lissner 2016-01-07 00:56:20 -05:00
parent 8e8708a1c8
commit d8c5bcc323
2 changed files with 10 additions and 1 deletions

View file

@ -16,8 +16,10 @@ local function tmuxpresskey(mod, key)
return false return false
end end
-- App settings
local iterm2
App.new("iTerm2") App.new("iTerm2")
.onInit(function (self, app) .onLaunched(function (self, app)
-- cmd+N for switching tmux windows -- cmd+N for switching tmux windows
for i = 1,9 do for i = 1,9 do
i = tostring(i) i = tostring(i)

View file

@ -28,6 +28,13 @@ App.new = function(name)
end end
self.onLaunched = function(fn) self.onLaunched = function(fn)
self.onLaunchedFn = fn self.onLaunchedFn = fn
local app = hs.application.find(self.name)
if app then
self.launch(app)
if app:isFrontmost() then
self.activate(app)
end
end
return self return self
end end
self.onTerminated = function(fn) self.onTerminated = function(fn)