Created
December 3, 2024 16:03
-
-
Save ohthehugemanatee/78a627a5e3aa941f9f0273fbb564f3d4 to your computer and use it in GitHub Desktop.
Script to enable/disable USB keyboard support on the Remarkable 2
This file contains hidden or 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
#!/bin/bash | |
# Script to enable/disable USB keyboard support on the remarkable 2. | |
# Just copy it to the rm2 over SSH, make it executable with chmod +x, and run it. | |
# You can confirm the change using `lsusb`. When this is enabled, you will see the host device and anything | |
# plugged into it. | |
# | |
# Then connect your keyboard using a powered USB OTG adapter. Bonus: the RM2 will charge while using it. | |
# In theory it is safe to keep "enabled" all the time, but TMK this has not been tested. It probably impacts battery life. | |
# All credit to https://github.com/dps/remarkable-keywriter/issues/14#issuecomment-1223341129 | |
# This script is provided as-is, no warranty is provided or implied. This script may hide your keys, anger your roommates, | |
# teach your pets to poop on your furniture, or do other awful things and IT'S NOT MY FAULT. | |
# Usage: rm-keyboard.sh {enable|disable} | |
# Check if the script is being run with root privileges. | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
# Function to display usage information. | |
usage() { | |
echo "Usage: $0 {enable|disable}" | |
exit 2 | |
} | |
# Check command line arguments. | |
if [ "$#" -ne 1 ]; then | |
usage | |
fi | |
ROLE_FILE="/sys/kernel/debug/ci_hdrc.0/role" | |
# Check if the role file exists. | |
if [ ! -f "$ROLE_FILE" ]; then | |
echo "The role file $ROLE_FILE does not exist. Ensure your system has the ci_hdrc module enabled." | |
exit 3 | |
fi | |
# Toggle the USB role based on the argument. | |
case "$1" in | |
enable) | |
echo "host" > "$ROLE_FILE" | |
echo "Enabled: USB role set to host." | |
;; | |
disable) | |
echo "gadget" > "$ROLE_FILE" | |
echo "Disabled: USB role set to gadget." | |
;; | |
*) | |
usage | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment