Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Wayland pynput v1.7.7 workaround #106

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions manim_voiceover/services/recorder/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ def __init__(self):
self.key_pressed = None

def on_press(self, key):
if not hasattr(key, "char"):
return True

if key.char == "r":
if hasattr(key, "r") or hasattr(key, "shift_r"):
self.key_pressed = True
elif hasattr(key, "char"):
if key.char == "r" or key.char == "shift_r":
self.key_pressed = True

return True

def on_release(self, key):
if not hasattr(key, "char"):
return True

if key.char == "r":
if hasattr(key, "r") or hasattr(key, "shift_r"):
self.key_pressed = False
elif hasattr(key, "char"):
if key.char == "r" or key.char == "shift_r":
self.key_pressed = False

return True

Expand Down Expand Up @@ -92,7 +92,7 @@ def _record(self, path):
self.listener = MyListener()
self.listener.start()

print("Press and hold the 'r' key to begin recording")
print("Press and hold the 'r' (or Shift^R if on Wayland) key to begin recording")
if self.first_call:
print("Wait for 1 second, then start speaking.")
print("Wait for at least 1 second after you finish speaking.")
Expand All @@ -103,7 +103,7 @@ def _record(self, path):
)
print("These instructions are only shown once.")

print("Release the 'r' key to end recording")
print("Release the 'r' (or Shift^R if on Wayland) key to end recording")
self.task = sched.scheduler(time.time, time.sleep)
self.event = self.task.enter(
self.callback_delay, 1, self._record_task, ([path])
Expand Down