fix: show app name toast on option key

This commit is contained in:
tri committed 2026-07-16 14:28:24 +07:00
1 parent 46d240e5cd
commit 2796c820d3
2 files changed
+9 -9

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@ return {
enabled = true, enabled = true,
duration = 0.7, duration = 0.7,
showOnFocus = true, showOnFocus = true,
showOnCommand = true, showOnOption = true,
style = { style = {
fillColor = { white = 0.08, alpha = 0.88 }, fillColor = { white = 0.08, alpha = 0.88 },
@@ -5,8 +5,8 @@ function AppNameToast.new(config)
return setmetatable({ return setmetatable({
config = config, config = config,
alertId = nil, alertId = nil,
commandKeyDown = false, optionKeyDown = false,
commandKeyWatcher = nil, optionKeyWatcher = nil,
shouldShow = nil, shouldShow = nil,
}, AppNameToast) }, AppNameToast)
end end
@@ -36,21 +36,21 @@ function AppNameToast:show()
end end
function AppNameToast:start() function AppNameToast:start()
if not self.config.showOnCommand then return self end if not self.config.showOnOption then return self end
self.commandKeyWatcher = hs.eventtap.new({ self.optionKeyWatcher = hs.eventtap.new({
hs.eventtap.event.types.flagsChanged, hs.eventtap.event.types.flagsChanged,
}, function(event) }, function(event)
local isCommandDown = event:getFlags().cmd == true local isOptionDown = event:getFlags().alt == true
if isCommandDown and not self.commandKeyDown then if isOptionDown and not self.optionKeyDown then
self:show() self:show()
end end
self.commandKeyDown = isCommandDown self.optionKeyDown = isOptionDown
return false return false
end) end)
self.commandKeyWatcher:start() self.optionKeyWatcher:start()
return self return self
end end