fix(hammerspoon): suppress duplicate app name toasts
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
e7729693df
commit
d37d12e5d8
2 files changed
+15
-2
No files matched your search
@@ -8,6 +8,7 @@ function AppNameToast.new(config)
|
||||
optionKeyDown = false,
|
||||
optionKeyWatcher = nil,
|
||||
shouldShow = nil,
|
||||
focusedAppPid = nil,
|
||||
}, AppNameToast)
|
||||
end
|
||||
|
||||
@@ -15,7 +16,7 @@ function AppNameToast:setShouldShow(predicate)
|
||||
self.shouldShow = predicate
|
||||
end
|
||||
|
||||
function AppNameToast:show()
|
||||
function AppNameToast:_show(skipIfAppUnchanged)
|
||||
if not self.config.enabled then return end
|
||||
if self.shouldShow and not self.shouldShow() then return end
|
||||
|
||||
@@ -23,6 +24,10 @@ function AppNameToast:show()
|
||||
local app = win and win:application() or nil
|
||||
if not app then return end
|
||||
|
||||
local appPid = app:pid()
|
||||
if skipIfAppUnchanged and appPid == self.focusedAppPid then return end
|
||||
self.focusedAppPid = appPid
|
||||
|
||||
if self.alertId then
|
||||
hs.alert.closeSpecific(self.alertId, 0)
|
||||
end
|
||||
@@ -35,6 +40,14 @@ function AppNameToast:show()
|
||||
)
|
||||
end
|
||||
|
||||
function AppNameToast:show()
|
||||
self:_show(false)
|
||||
end
|
||||
|
||||
function AppNameToast:showOnFocus()
|
||||
self:_show(true)
|
||||
end
|
||||
|
||||
function AppNameToast:start()
|
||||
if not self.config.showOnOption then return self end
|
||||
|
||||
|
||||
Reference in new issue
Block a user