Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions remarkable_mouse/remarkable_mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ def use_key(key):
log.debug("Detected {type(rm).__name__}")
log.debug(f'Pen:{rm.pen_file}\nTouch:{rm.touch_file}\nButton:{rm.button_file}')

return rm
return rm, client

def main():
client = None
ui_stopped = False
try:
parser = argparse.ArgumentParser(description="use reMarkable tablet as a mouse input")
parser.add_argument('--debug', action='store_true', default=False, help="enable debug messages")
Expand All @@ -146,6 +148,7 @@ def main():
parser.add_argument('--region', action='store_true', default=False, help="Use a GUI to position the output area. Overrides --monitor")
parser.add_argument('--threshold', metavar='THRESH', default=600, type=int, help="stylus pressure threshold (default 600)")
parser.add_argument('--evdev', action='store_true', default=False, help="use evdev to support pen pressure (requires root, Linux only)")
parser.add_argument('--stopui', action='store_true', default=False, help="forcibly stop reMarkable UI when connecting (DOES NOT SAVE OPEN DOCUMENTS)")

args = parser.parse_args()

Expand All @@ -157,13 +160,20 @@ def main():

# ----- Connect to device -----

rm = connect_rm(
rm, client = connect_rm(
address=args.address,
key=args.key,
password=args.password,
)
print("Connected to", args.address)

if args.stopui:
print("--stopui argument passed. Forcibly stopping reMarkable UI...")
print("UI will be restarted when remarkable_mouse is exited.")
print("If connection is lost before UI restarts, hold the reMarkable power button for 10 seconds, wait 5 seconds, then hold for 2 seconds, to reboot the device.")
ui_stopped = True
client.exec_command('systemctl stop xochitl')

# ----- Handle events -----

if args.evdev:
Expand All @@ -189,6 +199,10 @@ def main():
pass
except EOFError:
pass
finally:
if ui_stopped:
print("Restarting reMarkable UI...")
client.exec_command('systemctl start xochitl')

if __name__ == '__main__':
main()