Created
September 27, 2023 22:56
-
-
Save Elektordi/d4232e36911b60fb3351eda5d1a1b919 to your computer and use it in GitHub Desktop.
Slides remote passthrough
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import evdev | |
import xdo | |
dev = None | |
for d in [evdev.InputDevice(path) for path in evdev.list_devices()]: | |
# print(device.path, device.name, device.phys) | |
if d.name == "NORWII Norwii Wireless Presenter Keyboard": | |
dev = d | |
break | |
assert dev | |
dev.grab() | |
x = xdo.Xdo() | |
windows = x.search_windows(b".pptx ", only_visible=True, require=True) | |
print(windows) | |
assert windows | |
win = windows[0] | |
for event in dev.read_loop(): | |
if event.type == evdev.ecodes.EV_KEY: | |
key = evdev.categorize(event) | |
print(key) | |
if key.keystate != evdev.KeyEvent.key_down: | |
continue | |
if key.scancode == evdev.ecodes.KEY_DOWN: | |
press = b"Down" | |
elif key.scancode == evdev.ecodes.KEY_UP: | |
press = b"Up" | |
else: | |
print("(Key not implemented)") | |
continue | |
x.send_keysequence_window(win, press) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment