From 8e8708a1c8f3562042e7766fccf56981b634a5b9 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 7 Jan 2016 00:55:50 -0500 Subject: [PATCH] hs: modules/apps clean up --- hammerspoon/modules/apps.lua | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/hammerspoon/modules/apps.lua b/hammerspoon/modules/apps.lua index 693daef3..906fdae0 100644 --- a/hammerspoon/modules/apps.lua +++ b/hammerspoon/modules/apps.lua @@ -7,22 +7,17 @@ App.new = function(name) self.name = name self.bindings = {} - self.onInitFn = nil self.onActivateFn = nil self.onDeactivateFn = nil self.onLaunchedFn = nil self.onTerminatedFn = nil self.bind = function(mods, key, action, predicate) - table.insert(self.bindings, - {key = hs.hotkey.new(mods, key, action), predicate = predicate}) + table.insert(self.bindings, {key = hs.hotkey.new(mods, key, action), + predicate = predicate}) return self end - self.onInit = function(fn) - fn(self) - return self - end self.onActivate = function(fn) self.onActivateFn = fn return self @@ -66,11 +61,11 @@ App.new = function(name) self.enableBinds = function(self) hs.fnutils.each(self.bindings, function(b) - if b.predicate and not b.predicate() then - b.key:disable() - else - b.key:enable() - end + if b.predicate and not b.predicate() then + b.key:disable() + else + b.key:enable() + end end) end @@ -79,7 +74,7 @@ App.new = function(name) end self.clearBinds = function(self) - hs.fnutils.each(self.bindings, function(b) b.key:delete() end) + self:disableBinds() self.bindings = {} end