We cannot modify the plist file of MacGPG2 pinentry app because it will break its bunlde's code signature.
# ~/.gnupg/gpg-agent.conf
pinentry-program /opt/homebrew/bin/pinentry-mac /usr/libexec/PlistBuddy -c "Delete :LSUIElement" \
/opt/homebrew/Cellar/pinentry-mac/1.3.1.1/pinentry-mac.app/Contents/Info.plist codesign --force --deep --sign - \
/opt/homebrew/Cellar/pinentry-mac/1.3.1.1/pinentry-mac.app
gpgconf --kill gpg-agent│ Note: brew upgrade pinentry-mac will reset the LSUIElement change. │ Re-run the PlistBuddy + codesign steps after upgrades.
All below is obsolete..
UPDATE: this wont work, this breaks of course code signing of the /usr/local/MacGPG2/libexec/pinentry-mac.app App..
codesign --verify --deep --strict /usr/local/MacGPG2/libexec/pinentry-mac.app
DON'T USE THIS!
Whenever MacPGP's pinentry UI window pops up it has focus, but if I switch windows (i.e. to my pw manager) I cannot focus back to pinentry using the keyborad only (cannot be selected with cmd+tab).
gpgconf | grep pinentryExample output:
pinentry:Passphrase Entry:/usr/local/MacGPG2/libexec/pinentry-mac.app/Contents/MacOS/pinentry-mac
Save the .app bundle path (everything up to and including pinentry-mac.app) for the next steps:
PINENTRY_APP="$(gpgconf | awk -F: '/^pinentry:/{print $3}' | sed 's|/Contents/MacOS/.*||')"
echo "$PINENTRY_APP"/usr/libexec/PlistBuddy -c "Print :LSUIElement" "$PINENTRY_APP/Contents/Info.plist"- Prints
true→ flag is set (focus problem applies) - Prints
Does Not Exist→ nothing to do
LSUIElement (Launch Services UI Element) is an Info.plist flag that tells macOS the app is an "agent" / accessory app:
- No Dock icon
- Not in ⌘‑Tab application switcher
- No menu bar when focused
- Still can show windows
# Backup
sudo cp "$PINENTRY_APP/Contents/Info.plist" "$PINENTRY_APP/Contents/Info.plist.bak"
# Remove the flag
sudo /usr/libexec/PlistBuddy -c "Delete :LSUIElement" "$PINENTRY_APP/Contents/Info.plist"
# Tell LaunchServices to re-read the bundle
sudo /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f "$PINENTRY_APP"
killall cfprefsd 2>/dev/null
# Restart gpg-agent so the next prompt is fresh
gpgconf --kill gpg-agentecho test | gpg --clearsign >/dev/nullPinentry's window should now appear in ⌘‑Tab and have a Dock icon while open.
⚠️ GPG Suite updates may restore the originalInfo.plist. Just re‑run step 3 when that happens.