Skip to content

Commit

Permalink
Improve Linux compatibility for /write and /writeandsend buttons
Browse files Browse the repository at this point in the history
- Improved support for /write and /writeandsend commands on Linux using pynput
- Moved write logic to a dedicated write.py file
- Updated commands.py to use the new write function
  • Loading branch information
Lenochxd committed Dec 17, 2024
1 parent a422090 commit 7f61290
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
11 changes: 3 additions & 8 deletions app/buttons/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,9 @@ def handle_command(message=None):

elif message.startswith("/clearclipboard"):
system.clear_clipboard()

elif message.startswith("/write "):
keyboard.write(message.replace("/write ", ""))

elif message.startswith("/writeandsend "):
keyboard.write(message.replace("/writeandsend ", ""))
keyboard.press("ENTER")


elif message.startswith("/write"):
system.write(message)

elif message.startswith(("/appvolume +", "/appvolume -", "/appvolume set")):
if not is_win:
Expand Down
1 change: 1 addition & 0 deletions app/buttons/system/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from .taskkill import kill
from .restart_app import restart_app
from .clear_clipboard import clear_clipboard
from .write import handle_command as write
24 changes: 24 additions & 0 deletions app/buttons/system/write.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from app.utils.platform import is_windows

import keyboard
import pyautogui
from pynput.keyboard import Controller
pynput = Controller()


def write(text):
if is_windows:
keyboard.write(text)
else:
pynput.type(text)


def handle_command(message):
text = message.replace("/writeandsend", "",1).replace("/write", "", 1).strip()

if message.startswith("/writeandsend "):
write(text)
pyautogui.press("enter")

if message.startswith("/write "):
write(text)

0 comments on commit 7f61290

Please sign in to comment.