Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
🐳 chore(*): fix a non-functioning openrazer
Browse files Browse the repository at this point in the history
  • Loading branch information
c0deplayer committed Sep 28, 2023
1 parent 5803bff commit ce92e2f
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 8 deletions.
62 changes: 62 additions & 0 deletions config/files/usr/lib/udev/razer_mount
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/sh

# Exit on error
set -e

PATH='/sbin:/bin:/usr/sbin:/usr/bin'

if [ -x /usr/bin/logger ]; then
LOGGER=/usr/bin/logger
elif [ -x /bin/logger ]; then
LOGGER=/bin/logger
else
unset LOGGER
fi

# for diagnostics
if [ -t 1 -a -z "$LOGGER" ] || [ ! -e '/dev/log' ]; then
mesg() {
echo "$@" >&2
}
elif [ -t 1 ]; then
mesg() {
echo "$@"
$LOGGER -t "${0##*/}[$$]" "$@"
}
else
mesg() {
$LOGGER -t "${0##*/}[$$]" "$@"
}
fi

DRIVER=$1
DEVICE_ID=$2

mesg "Driver $DRIVER"
mesg "Device_ID $DEVICE_ID"

if [ ! -d /sys/bus/hid/drivers/"$DRIVER" ] ; then
mesg "Modprobing $DRIVER"
modprobe "$DRIVER"
sleep 0.05
mesg "Modprobed $DRIVER"
fi

for GENERIC_DRIVER in "razer" "hid-generic"; do
if [ -d /sys/bus/hid/drivers/"$GENERIC_DRIVER"/"$DEVICE_ID" ] ; then
# Unbind from hid
mesg "Unbinding $DEVICE_ID from $GENERIC_DRIVER"
printf '%s' "$DEVICE_ID" > /sys/bus/hid/drivers/"$GENERIC_DRIVER"/unbind
mesg "Binding $DEVICE_ID to $DRIVER"
printf '%s' "$DEVICE_ID" > /sys/bus/hid/drivers/"$DRIVER"/bind
sleep 0.1
mesg "Finished binding $DEVICE_ID"
fi
done

if [ -d /sys/bus/hid/drivers/"$DRIVER"/"$DEVICE_ID" ] ; then
mesg "Changing group /sys/bus/hid/drivers/$DRIVER/$DEVICE_ID/"
chgrp -R plugdev /sys/bus/hid/drivers/"$DRIVER"/"$DEVICE_ID"/
mesg "Changed group /sys/bus/hid/drivers/$DRIVER/$DEVICE_ID/"
fi

39 changes: 39 additions & 0 deletions config/files/usr/lib/udev/rules.d/99-razer.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
ACTION!="add", GOTO="razer_end"
SUBSYSTEMS=="usb|input|hid", ATTRS{idVendor}=="1532", GOTO="razer_vendor"
GOTO="razer_end"

LABEL="razer_vendor"

# Mice
ATTRS{idProduct}=="0013|0016|0020|0024|0025|0029|002e|002f|0032|0034|0036|0037|0038|0039|003e|003f|0040|0041|0042|0043|0044|0045|0046|0048|004c|004f|0050|0053|0054|0059|005a|005b|005c|005e|0060|0062|0064|0065|0067|006a|006b|006c|006e|006f|0070|0071|0072|0073|0077|0078|007a|007b|007c|007d|0080|0083|0084|0085|0086|0088|008a|008c|008d|008f|0090|0091|0094|0095|0096|0098|0099|009a|009c|009e|009f|00a1|00a5|00a6|00aa|00ab|00b2|00b3|00b6|00b7", \
ATTRS{idVendor}=="1532", \
ENV{ID_RAZER_CHROMA}="1", ENV{RAZER_DRIVER}="razermouse"

# Keyboards
ATTRS{idProduct}=="010d|010e|010f|0111|0113|0118|011a|011b|011c|0201|0202|0203|0204|0205|0207|0208|0209|020f|0210|0211|0214|0216|0217|021a|021e|021f|0220|0221|0224|0225|0226|0227|0228|022a|022b|022c|022d|022f|0232|0233|0234|0235|0237|0239|023a|023b|023f|0240|0241|0243|0245|0246|024a|024c|024d|024e|0252|0253|0255|0256|0257|0258|0259|025a|025d|025e|0266|0269|026a|026b|026c|026d|026e|026f|0270|0271|0276|0279|027a|0282|028a|028b|028c|0290|0292|0294|0295|0296|0298|029e|029f|02a0|02a2|0a24", \
ATTRS{idVendor}=="1532", \
ENV{ID_RAZER_CHROMA}="1", ENV{RAZER_DRIVER}="razerkbd"

# Kraken
ATTRS{idProduct}=="0501|0504|0506|0510|0527", \
ATTRS{idVendor}=="1532", \
ENV{ID_RAZER_CHROMA}="1", ENV{RAZER_DRIVER}="razerkraken"

# Accessories (Speakers, Mousemats, Razer Core, etc)
ATTRS{idProduct}=="0068|007e|0215|0517|0518|0c00|0c01|0c02|0c04|0f07|0f08|0f09|0f0d|0f12|0f19|0f1a|0f1d|0f1f|0f20|0f21|0f26|0f2b", \
ATTRS{idVendor}=="1532", \
ENV{ID_RAZER_CHROMA}="1", ENV{RAZER_DRIVER}="razeraccessory"

# Get out if no match
ENV{ID_RAZER_CHROMA}!="1", GOTO="razer_end"

# Set permissions if this is an input node
SUBSYSTEM=="usb|input|hid", GROUP:="plugdev"

# We're done unless it's the hid node
SUBSYSTEM!="hid|usb", GOTO="razer_end"

# Rebind if needed
SUBSYSTEM=="hid|usb", RUN+="razer_mount $env{RAZER_DRIVER} $kernel"

LABEL="razer_end"
1 change: 1 addition & 0 deletions config/recipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ modules:

- type: script
scripts:
- openrazer.sh
- signing.sh
12 changes: 4 additions & 8 deletions config/scripts/openrazer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

set -oue pipefail

# Only run if OS_VERSION is not 39
if grep -qv "39" <<< "$OS_VERSION"; then
rpm-ostree install \
kernel-devel-matched \
kernel-tools \
/tmp/akmods/rpms/kmods/*openrazer*.rpm \
/tmp/akmods/rpms/kmods/*openrgb*.rpm
fi
cp /tmp/config/files/usr/lib/udev/rules.d/99-razer.rules /usr/lib/udev/rules.d/99-razer.rules
cp /tmp/config/files/usr/lib/udev/razer_mount /usr/lib/udev/razer_mount

getent group plugdev >/dev/null || groupadd -r plugdev

0 comments on commit ce92e2f

Please sign in to comment.