feat: Implement interactive shortcut selection

This commit enhances your experience for setting a keyboard shortcut. Instead of typing the shortcut as a string, you are now prompted to press the desired key combination directly.

The `src/config.py` module has been updated to:
- Use `keyboard.read_hotkey()` to capture the key combination you press.
- Display the captured shortcut for confirmation.
- Save the shortcut only after you confirm it is correct.

This provides a more intuitive and less error-prone way for you to configure your preferred shortcut.
This commit is contained in:
google-labs-jules[bot]
2025-08-09 22:17:15 +00:00
parent 3aad8080f4
commit 31c79a36fc
3 changed files with 32 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ import threading
import pystray
from PIL import Image
import re
from config import get_shortcut
def convert_en_characters(input_str):
"""
@@ -136,9 +137,10 @@ def main():
tray_thread = threading.Thread(target=setup_tray, daemon=True)
tray_thread.start()
# Register the keyboard shortcut (Ctrl + Space)
keyboard.add_hotkey('ctrl+space', on_shortcut)
print("Press Ctrl + Space to convert text to Persian.")
# Register the keyboard shortcut
shortcut = get_shortcut()
keyboard.add_hotkey(shortcut, on_shortcut)
print(f"Press {shortcut} to convert text to Persian.")
# Keep the script running
keyboard.wait()