From f831081fb8795d131386172efa84546fccc0585a Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Wed, 8 Jan 2020 12:10:40 -0800 Subject: [PATCH] [hammerspoon] add stop method to quitter --- .hammerspoon/Spoons/Quitter.spoon/init.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.hammerspoon/Spoons/Quitter.spoon/init.lua b/.hammerspoon/Spoons/Quitter.spoon/init.lua index 3e31d69..5d61a24 100644 --- a/.hammerspoon/Spoons/Quitter.spoon/init.lua +++ b/.hammerspoon/Spoons/Quitter.spoon/init.lua @@ -32,13 +32,13 @@ function obj:start() self:reset() -- Reset if we're waking from sleep - hs.caffeinate.watcher.new(function(event) + self.watcher = hs.caffeinate.watcher.new(function(event) if event ~= hs.caffeinate.watcher.systemDidWake then return end self:reset() end) -- Set last focused time for relevant apps - hs.window.filter.default:subscribe(hs.window.filter.windowFocused, function(window, appName) + self.windowFilter = hs.window.filter.default:subscribe(hs.window.filter.windowFocused, function(window, appName) local bundleID = window:application():bundleID() if not self.quitAppsAfter[bundleID] then return end self.lastFocused[bundleID] = os.time() @@ -51,6 +51,18 @@ function obj:start() return self end +--- Quitter:stop() +--- Method +--- Stop Quitter +--- +--- Parameters: +--- * None +function obj:stop() + self.watcher:stop() + self.windowFilter:unsubscribe() + self.timer:stop() +end + function obj:reset() hs.fnutils.ieach(hs.application.runningApplications(), function(app) local bundleID = app:bundleID()