fix(macos): skip HotkeyListener on darwin (keyboard lib has no macOS support)#3
Open
l984-451 wants to merge 1 commit into
Open
fix(macos): skip HotkeyListener on darwin (keyboard lib has no macOS support)#3l984-451 wants to merge 1 commit into
l984-451 wants to merge 1 commit into
Conversation
The `keyboard` library does not support modifier+letter global hotkeys
on macOS — `keyboard.add_hotkey('ctrl+shift+b', ...)` raises
ValueError('Unrecognized character: b'). The error message blames
"administrator" permissions, but no amount of sudo makes the lib work.
Skip the listener entirely on macOS so the error and the bogus Input
Monitoring permission prompt go away. A future commit can wire up
`pynput` as a proper macOS-native replacement.
Owner
|
hi @l984-451 thanks for the PR couple of things before i merge:
something like: # capture/hotkey.py - top of start()
def start(self):
if self._running:
return
if sys.platform == "darwin":
print("[Hotkey] Disabled on macOS (keyboard library lacks modifier+letter support). Use the dashboard.")
return
# ... existing registration code
thanks for the contribution 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS, starting ScreenMind logs:
The error message blames missing admin permissions, but the real cause is that the
keyboardlibrary does not support modifier+letter hotkeys on macOS at all —keyboard.add_hotkey('ctrl+shift+b', ...)can't parse the keymap. Running withsudodoes not fix it. ThekeyboardREADME itself notes "MacOS support is limited".A separate side effect: even though
add_hotkeyfails, the attempt installs a low-level event tap that triggers an Input Monitoring permission prompt on every launch. Annoying and not actionable.Fix
Skip
HotkeyListener.start()(and.stop()) onsys.platform == "darwin"and print a one-liner explaining why. Existing behavior on Windows and Linux is unchanged.This is a minimal stopgap. The proper fix is to swap
keyboardforpynput(which has real macOS support) — happy to follow up with that PR if there's interest.