[hammerspoon] update Quitter spoon

pull/37/head
Alpha Chen 3 years ago
parent 7fafb528ef
commit a3d6891d11

@ -12,12 +12,8 @@ obj.version = "0.1"
obj.author = "Alpha Chen <alpha@kejadlen.dev>" obj.author = "Alpha Chen <alpha@kejadlen.dev>"
obj.license = "MIT - https://opensource.org/licenses/MIT" obj.license = "MIT - https://opensource.org/licenses/MIT"
obj.logger = hs.logger.new("quitter", "debug") obj.logger = hs.logger.new("quitter")
obj.lastFocused = {} obj.lastFocused = {}
obj.windowFocusedFn = function(window, appName)
local name = window:application():name()
obj.lastFocused[name] = os.time()
end
--- Quitter.quitAppsAfter --- Quitter.quitAppsAfter
--- Variable --- Variable
@ -44,7 +40,10 @@ function obj:start()
for app, _ in pairs(self.quitAppsAfter) do for app, _ in pairs(self.quitAppsAfter) do
self.windowFilter:allowApp(app) self.windowFilter:allowApp(app)
end end
self.windowFilter:subscribe(hs.window.filter.windowFocused, self.windowFocusedFn) self.windowFilter:subscribe(hs.window.filter.windowFocused, function(window, appName)
local name = window:application():name()
obj.lastFocused[name] = os.time()
end)
self.timer = hs.timer.doEvery(60, function() self.timer = hs.timer.doEvery(60, function()
self:reap() self:reap()

Loading…
Cancel
Save