Created
July 21, 2023 19:16
-
-
Save Mimickal/f7f9a26efce64dac7c1365725cb45089 to your computer and use it in GitHub Desktop.
Sets up an Infinity IN-USB-2 Foot Pedal to act as a keyboard on Debian-based Linux systems
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
#!/bin/bash | |
# Sets up an Infinity IN-USB-2 foot pedal so it behaves like a keyboard. | |
# This script assumes a Debian-based system. | |
# ID 05f3:00ff PI Engineering, Inc. VEC Footpedal | |
# See: https://thejeshgn.com/2022/05/03/usb-foot-pedal-or-switch-as-a-keyboard-in-linux/ | |
RULE_FILE=/etc/udev/rules.d/10-vec-usb-footpedal.rules | |
HWDB_FILE=/etc/udev/hwdb.d/000-vec-usb-footpedal.hwdb | |
RULE_DATA=$(cat <<END | |
ACTION=="add|change", | |
KERNEL=="event[0-9]*", | |
ATTRS{idVendor}=="05f3", | |
ATTRS{idProduct}=="00ff", | |
ENV{ID_INPUT_KEYBOARD}="1" | |
END | |
) | |
# NOTE: Keyboard mapping can be configured here. | |
# Pedals defined in left-to-right order. | |
HWDB_DATA=$(cat <<END | |
evdev:input:b*v05F3p00FF* | |
KEYBOARD_KEY_90001=b | |
KEYBOARD_KEY_90002=n | |
KEYBOARD_KEY_90003=m | |
END | |
) | |
if [[ $(id -u) != 0 ]]; then | |
echo "Warning: Not running as root! This script probably won't work." | |
echo | |
fi | |
echo "Setting up Infinity IN-USB-2 Foot Pedal" | |
echo | |
echo "Creating udev rules entry $RULE_FILE" | |
# Don't use quotes here so this all ends up on one line | |
echo $RULE_DATA | tee $RULE_FILE | |
echo | |
echo "Creating udev hwdb entry $HWDB_FILE" | |
echo "$HWDB_DATA" | tee $HWDB_FILE | |
echo | |
echo "Reloading services..." | |
echo | |
udevadm control --reload | |
systemd-hwdb update | |
echo | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment