-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathwtype.py
30 lines (22 loc) · 1.06 KB
/
wtype.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from subprocess import run
from ..abstractionhelper import is_installed, is_wayland
from ..action import __get_codepoints as get_codepoints
from .typer import Typer
class WTypeTyper(Typer):
@staticmethod
def supported() -> bool:
return is_wayland() and is_installed("wtype")
@staticmethod
def name() -> str:
return "wtype"
def get_active_window(self) -> str:
return "not possible with wtype"
def type_characters(self, characters: str, active_window: str) -> None:
run(["wtype", characters])
def insert_from_clipboard(self, active_window: str) -> None:
run(["wtype", "-M", "shift", "-P", "Insert", "-p", "Insert", "-m", "shift"])
def type_numerical(self, characters: str, active_window: str) -> None:
for character in characters:
unicode_codepoint = get_codepoints(character)
# Run Ctrl+Shift+U + the unicode codepoint, then release Ctrl and Shift
run(["wtype", "-M", "ctrl"," -M", "shift", "u"] + [p for p in unicode_codepoint] + ["-m", "ctrl", "-m", "shift"])