hammerspoon icon indicating copy to clipboard operation
hammerspoon copied to clipboard

`app:hide()` not work for some specific apps and always returns `false`

Open keidarcy opened this issue 1 year ago • 3 comments

Chrome works fine with app:hide() but ARC not and app.hide() always returns false even hide() worked.

local log = hs.logger.new("toggle-me", "debug")
bundleId = "com.google.Chrome"
// bundleId = "company.thebrowser.Browser"
local app = hs.application.find("com.google.Chrome")
if app:isFrontmost() then
  local h = app:hide()
  log.i(h) // alway false
end

I'm binding cmd+h for arc as a workaround.

I have accessibility enabled.

More details in my runnning script: hide,bind cmd + h

keidarcy avatar Jan 05 '24 03:01 keidarcy

I found a quick-and-dirty workaround:

local name
if app and app.name then
  name = app.name
elseif type(app) == "string" then
  name = app
end
if name then curr:selectMenuItem("Hide " .. name) end

theutz avatar Mar 04 '24 22:03 theutz

I have the same problem. This works for all apps except ARC

hs.hotkey.bind({"cmd", "alt"}, "a", function()
  local arc = hs.application.find("arc")
  if arc:isFrontmost() then
    arc:hide()
  else
    hs.application.launchOrFocus("/Applications/Arc.app")
  end
end)

gandhiShepard avatar May 02 '24 21:05 gandhiShepard

Came here to report the same problem and found this issue.

For now, I'm special-casing Arc in my openOrHideOrShowApp key-handler function and calling selectMenuItem instead of hide when isFrontmost is Arc (just like @theutz suggested above).

Any idea what's "special" about Arc?

eddyg avatar May 31 '24 12:05 eddyg

ARC likely isn't properly implementing Accessibility, which is the interface by which we're able to hide/unhide apps. That being the case, there isn't much we can do about it other than add workarounds in configs like those shown here.

cmsj avatar Aug 06 '24 12:08 cmsj