Last active
December 12, 2021 18:30
-
-
Save rntz/75dda2a991a05d77feacb8aa2e5d25d3 to your computer and use it in GitHub Desktop.
This file contains 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
from talon import Module, Context, actions | |
mod = Module() | |
ctx = Context() | |
subtitles_enabled = None | |
def update_subtitles(state): | |
global subtitles_enabled | |
subtitles_enabled = state | |
if subtitles_enabled is not None: | |
ctx.settings = {"speech._subtitles": subtitles_enabled} | |
else: | |
ctx.settings = {} | |
@mod.action_class | |
class ModuleActions: | |
def subtitles_enable(): | |
"""Enable subtitles temporarily.""" | |
update_subtitles(True) | |
def subtitles_disable(): | |
"""Disable subtitles temporarily.""" | |
update_subtitles(False) | |
def subtitles_restore(): | |
"""Restore subtitles to default state.""" | |
update_subtitles(None) |
This file contains 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
subtitles on: user.subtitles_enable() | |
subtitles off: user.subtitles_disable() | |
subtitles restore: user.subtitles_restore() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment