Skip to content

Commit

Permalink
fix the ydotool type code to get the correct event code
Browse files Browse the repository at this point in the history
  • Loading branch information
relma2 committed Dec 23, 2024
1 parent 48ea0b5 commit 9a5665c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/picker/abstractionhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_event_code(char: str, pressrelease: bool = True) -> str:
with open("/usr/include/linux/input-event-codes.h") as file:
for line in file:
# Line is of the form #define keypress event_code
if keypress in line:
if keypress in line.split():
event_code = line.split()[2]
break

Expand Down
6 changes: 2 additions & 4 deletions src/picker/typer/ydotool.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,13 @@ def type_characters(self, characters: str, active_window: str) -> None:
Shift_release = get_event_code("LeftShift", False)
U_release = get_event_code("U", False)
points = []
points_release = []

for point in unicode_code_point:
points.append(get_event_code(point))
points_release.append(get_event_code(point, False))
points_release.reverse()
points.append(get_event_code(point, False))

# Send the event codes to ydotool
the_array = ["ydotool", "key", Ctrl, Shift, U,] + points + [Shift_release, Ctrl_release, U_release] + points_release
the_array = ["ydotool", "key", "--key-delay", "1", Ctrl, Shift, U, U_release] + points + [Shift_release, Ctrl_release]
run(the_array, env=os.environ.copy().update({"YDOTOOL_SOCKET": self.socket}))

def insert_from_clipboard(self, active_window: str) -> None:
Expand Down

0 comments on commit 9a5665c

Please sign in to comment.