Last active
June 6, 2026 04:00
-
-
Save claabs/e5971bf8d4607c4355a7d7813a14c74e to your computer and use it in GitHub Desktop.
Batocera service to set a udev rule that persists through upgrades, in this case, the Lossless GC adapter
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/sh | |
| case "$1" in | |
| start) | |
| # Ensure the destination directory exists | |
| mkdir -p /etc/udev/rules.d/ | |
| # Create the udev rule directly in the volatile root filesystem | |
| cat << 'EOF' > /etc/udev/rules.d/99-gamecube-adapter.rules | |
| ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="0337", DRIVER=="usbhid", RUN+="/bin/sh -c 'echo -n $kernel > /sys/bus/usb/drivers/usbhid/unbind'" | |
| EOF | |
| # Reload and trigger the rule immediately | |
| udevadm control --reload-rules | |
| udevadm trigger | |
| ;; | |
| stop) | |
| # Clean up the rule file when stopping the service | |
| rm -f /etc/udev/rules.d/99-gamecube-adapter.rules | |
| udevadm control --reload-rules | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment