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,7 +8,7 @@ local appNameToast = AppNameToast.new(config.appNameToast)
|
|||||||
local windowHighlight = WindowHighlight.new(config.windowHighlight, {
|
local windowHighlight = WindowHighlight.new(config.windowHighlight, {
|
||||||
onWindowFocused = function()
|
onWindowFocused = function()
|
||||||
if config.appNameToast.showOnFocus then
|
if config.appNameToast.showOnFocus then
|
||||||
appNameToast:show()
|
appNameToast:showOnFocus()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ function AppNameToast.new(config)
|
|||||||
optionKeyDown = false,
|
optionKeyDown = false,
|
||||||
optionKeyWatcher = nil,
|
optionKeyWatcher = nil,
|
||||||
shouldShow = nil,
|
shouldShow = nil,
|
||||||
|
focusedAppPid = nil,
|
||||||
}, AppNameToast)
|
}, AppNameToast)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ function AppNameToast:setShouldShow(predicate)
|
|||||||
self.shouldShow = predicate
|
self.shouldShow = predicate
|
||||||
end
|
end
|
||||||
|
|
||||||
function AppNameToast:show()
|
function AppNameToast:_show(skipIfAppUnchanged)
|
||||||
if not self.config.enabled then return end
|
if not self.config.enabled then return end
|
||||||
if self.shouldShow and not self.shouldShow() 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
|
local app = win and win:application() or nil
|
||||||
if not app then return end
|
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
|
if self.alertId then
|
||||||
hs.alert.closeSpecific(self.alertId, 0)
|
hs.alert.closeSpecific(self.alertId, 0)
|
||||||
end
|
end
|
||||||
@@ -35,6 +40,14 @@ function AppNameToast:show()
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function AppNameToast:show()
|
||||||
|
self:_show(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
function AppNameToast:showOnFocus()
|
||||||
|
self:_show(true)
|
||||||
|
end
|
||||||
|
|
||||||
function AppNameToast:start()
|
function AppNameToast:start()
|
||||||
if not self.config.showOnOption then return self end
|
if not self.config.showOnOption then return self end
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user