diff --git a/nvda/nvda.py b/nvda/nvda.py index b00fd5c..bcdd147 100644 --- a/nvda/nvda.py +++ b/nvda/nvda.py @@ -2,6 +2,7 @@ import os import time from typing import ClassVar + from talon import Context, Module, actions, clip, cron, scope, settings, speech_system mod = Module() diff --git a/voiceover/readme.md b/voiceover/readme.md index 278eb17..74860fa 100644 --- a/voiceover/readme.md +++ b/voiceover/readme.md @@ -1,6 +1,6 @@ # VoiceOver -This integration is a work in progress. VoiceOver is difficult to customize or script since it is all closed source and most of the best APIs are only able to be queried via objc or swift, not Python unless ffi is brought into play. +This integration is a work in progress. VoiceOver is difficult to customize or script since it is all closed source and most of the best APIs are only able to be queried via objc or swift, not Python unless ffi is brought into play. ## Setup diff --git a/voiceover/voiceover.py b/voiceover/voiceover.py index d6c8f0f..db4ff3e 100644 --- a/voiceover/voiceover.py +++ b/voiceover/voiceover.py @@ -11,6 +11,7 @@ from talon.mac import applescript + @ctx.action_class("user") class MacActions: def toggle_reader(): @@ -28,6 +29,7 @@ def with_voiceover_mod_press(key: str): mod.tag("voiceover_running", desc="If set, voiceover is running") + @mod.scope def set_voiceover_running_tag(): """Update tags based on if voiceover is running""" @@ -51,7 +53,7 @@ def is_voiceover_running() -> bool: """Returns true if voiceover is running""" if os.name != "darwin": return False - + # TODO : figure out how a way to check this without spamming subprocesses return False @@ -78,17 +80,16 @@ def with_voiceover_mod_press(key: str): class VoiceoverActions: def tts(text: str, interrupt: bool = True): """text to speech with voiceover""" - def wrapper(text): res = applescript.run( - f""" + f""" tell application "VoiceOver" output "{text}" end tell """ ) + # spawn it on a different thread so if it stalls we don't hang cron.after("0s", lambda: wrapper(text)) - diff --git a/voiceover/voiceover.talon b/voiceover/voiceover.talon index 8bb45eb..182e9d0 100644 --- a/voiceover/voiceover.talon +++ b/voiceover/voiceover.talon @@ -1,16 +1,12 @@ -os: mac - +os: mac - read below: key(ctrl-alt-a) -next heading: key(cmd-ctrl-alt-h) +next heading: key(cmd-ctrl-alt-h) previous heading: key(cmd-ctrl-alt-shift-h) next landmark: key(ctrl-alt-cmd-n) # TODO voiceover mod not working -reader help: - user.with_voiceover_mod_press("h") - -screen curtain: - user.with_voiceover_mod_press("shift-fn-_") +reader help: user.with_voiceover_mod_press("h") +screen curtain: user.with_voiceover_mod_press("shift-fn-_")