Skip to content

Instantly share code, notes, and snippets.

@spaskalev
Created September 7, 2020 18:58
Show Gist options
  • Save spaskalev/70a72be73f8db67e3146c44b9c377c83 to your computer and use it in GitHub Desktop.
Save spaskalev/70a72be73f8db67e3146c44b9c377c83 to your computer and use it in GitHub Desktop.
remote keyboard on LibreELEC from another linux box
#
# NOTE: make sure to update the device paths on both scripts
#
#
# server - run this on LibreELEC via /storage/.config/autostart.sh
#
#!/bin/sh
EV_DEV="/dev/input/by-id/usb-Microsoft_Wired_Keyboard_400-event-kbd"
AUTH_DEV="/sys/bus/usb/devices/1-1.4/authorized"
DELAY="1s"
while true; do
# reset the device
echo 0 > "${AUTH_DEV}"
sleep "${DELAY}"
echo 1 > "${AUTH_DEV}"
sleep "${DELAY}"
# poor man's keepalive - force nc to close the connection after a client is gone
# by having tee output whatever it has received back to nc while sending it
# to the evdev device at the same time
nc -l -p 1337 -e tee -a "${EV_DEV}"
sleep "${DELAY}"
done
#
# client - run this on your machine
#
#!/bin/sh
EV_DEV="/dev/input/by-id/usb-04d9_USB_Keyboard-event-kbd"
TARGET_HOST="192.168.88.231"
TARGET_PORT="1337"
DELAY="1s"
while true; do
nc "${TARGET_HOST}" "${TARGET_PORT}" < "${EV_DEV}" 2>&1 1>/dev/null
echo "Connecting.."
sleep "${DELAY}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment