2

This is a slightly obscure issue, so I'll do my best to describe it as well as what I've already tried. I have just started using macOS Monterey, and I suspect that the new macOS version has broken my workflow.

I have a hotkey bound in Hammerspoon, which launches a very light GUI chooser-menu app (to auto-fill passwords from pass). It still works (unchanged for a few years now), except when a password field (i.e., NSSecureTextField) is key and has focus. This hasn't been an issue in previous macOS versions, and the same setup (via versioned dotfiles) works fine in Big Sur, unchanged.

Here's my setup, roughly: (it is stripped down from what I normally use, but reproduces the issue. keuze refers to a fork of https://github.com/JodusNodus/keuze I have been trying out. The "real" keuze can't be invoked like this, but I've forked it and hard-coded a prompt text and list of options for testing purposes.)

Hammerspoon keybinding:

hs.hotkey.bind({"alt", "shift"}, "i", function()
    local output, status, exit_type, rc = hs.execute("~/src/keuze/build/Release/keuze", false)

    if status then
      hs.eventtap.keyStrokes(trim(output))
    end
end)

When I run ~/src/keuze/build/Release/keuze from the Terminal it shows as expected, and it also shows as expected when using my Hammerspoon keybinding. Only when an NSSecureTextField has focus, the keuze app is started but has no focus.

I should add that if I attempt to use a native Hammerspoon hs:chooser as follows, it successfully gets focus, even when I invoke it from inside a password field:

hs.hotkey.bind({"alt", "shift"}, "o", function()
    local chooser = hs.chooser.new(function(choice)
    end)
    local windows = {}
    chooser
      :placeholderText("Whatever bleep bloop")
      :searchSubText(true)
      :choices(windows)
      :show()
end)

I did notice that when I enabled Console.app's log streaming feature, select a password field, and trigger the keybinding, there is one suspicious entry that seems to be a smoking gun:

error 18:20:36.254859+1100 WindowServer CPS: Denying keuze the right to be in front because secureTextInput is active and this process doesn't have secure text mode enabled, and this request was not caused by user activity

Subsystem: com.apple.SkyLight

This made me reflect that Hammerspoon needs to be added to System Preferences > Security & Privacy > Privacy > Accessibility, so I tried to add my binary (~/src/keuze/build/Release/keuze) to that list, too. That has made no difference. How can I either launch the process in a way that macOS believes it's in response to user activity, or perhaps "enable secure text mode" they refer to?

I have Googled for various bits of that error message such as "secureTextInput is active and this process doesn't have secure text mode", and there don't seem to be any good leads! Except this Alfred forum post, which may or may not pan out: https://www.alfredforum.com/topic/17449-opening-problem-on-monterey-after-clicking-on-password-field/.

Thank you for your patience reading this long write-up

PS: From what I can tell, this secure text mode refers to a feature introduced in the Carbon / 10.3-10.4 (!) era, but I can't find hints as to how to legitimately work with it.

RogerTheDragon
  • 267
  • 1
  • 10
  • I wanted to add the tags `monterey` and `nssecuretextfield` because I believe they're very relevant, but did not have the SO Reputation required. – RogerTheDragon Nov 15 '21 at 07:29
  • Looks like Apple added a security feature in macOS 12: https://lapcatsoftware.com/articles/monterey-security.html – Jonny Aug 15 '22 at 03:12

0 Answers0