ideasman42 / nerd-dictation

Simple, hackable offline speech to text - using the VOSK-API.
GNU General Public License v3.0
1.3k stars 107 forks source link

[TODO] Wayland support #45

Closed jjgalvez closed 2 years ago

jjgalvez commented 2 years ago

First, very cool application! I use wayland on KDE and found that ydotool (https://github.com/ReimuNotMoe/ydotool) works pretty well as a replacement for xdotool. To use ydotool I changed the command from xdotool to ydotool, removed the --clearmodifiers and changed the backspace command from ["backspace" to ['14', '14:0'] Ydotool is a bit harder to use because of wayland, but it works with both x and wayland so I find that a plus

ideasman42 commented 2 years ago

Hi, ydotool support would be much appreciated.

rtzu6 commented 2 years ago

Alternatively, wtype also seems to work.

diff --git a/nerd-dictation b/nerd-dictation
index 1d6b626..1df4372 100755
--- a/nerd-dictation
+++ b/nerd-dictation
@@ -61,11 +61,9 @@ USER_CONFIG = "nerd-dictation.py"

 def run_xdotool(subcommand: str, payload: List[str]) -> None:
-    cmd_base = "xdotool"
+    cmd_base = "wtype"
     cmd = [
         cmd_base,
-        subcommand,
-        "--clearmodifiers",
     ] + payload
     try:
         subprocess.check_output(cmd)
@@ -1052,8 +1050,8 @@ def main_begin(

         def handle_fn(text: str, delete_prev_chars: int) -> None:
             if delete_prev_chars:
-                run_xdotool("key", ["BackSpace"] * delete_prev_chars)
-            run_xdotool("type", ["--", text])
+                run_xdotool("key", ["-P","BACKSPACE"] * delete_prev_chars)
+            run_xdotool("type", [text])

     elif output == "STDOUT":
jjgalvez commented 2 years ago

wtype currently does not work with KDE Plasma because Plasma has not yet implemented some specific protocol, however ydotool does work with Plasma, perhaps it can also be added to the list of tools similar to wtype