From d8c5bcc3237b6b3dd5076d606e41d811992cf2b7 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 7 Jan 2016 00:56:20 -0500 Subject: [PATCH] hs: remove onInit, use onLaunched --- hammerspoon/apps/iterm.lua | 4 +++- hammerspoon/modules/apps.lua | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hammerspoon/apps/iterm.lua b/hammerspoon/apps/iterm.lua index 00d6437a..7f96457c 100644 --- a/hammerspoon/apps/iterm.lua +++ b/hammerspoon/apps/iterm.lua @@ -16,8 +16,10 @@ local function tmuxpresskey(mod, key) return false end +-- App settings +local iterm2 App.new("iTerm2") - .onInit(function (self, app) + .onLaunched(function (self, app) -- cmd+N for switching tmux windows for i = 1,9 do i = tostring(i) diff --git a/hammerspoon/modules/apps.lua b/hammerspoon/modules/apps.lua index 906fdae0..2dbb510c 100644 --- a/hammerspoon/modules/apps.lua +++ b/hammerspoon/modules/apps.lua @@ -28,6 +28,13 @@ App.new = function(name) end self.onLaunched = function(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 end self.onTerminated = function(fn)