arc-addons/ledcontrol/all/usr/bin/ugreen-probe-leds
AuxXxilium ebf5d5ca84 ledcontrol: update for upcoming changes
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
2024-10-24 18:28:38 +02:00

22 lines
703 B
Bash
Executable File

#!/usr/bin/bash
set -e
{ lsmod | grep i2c-dev ; } || modprobe -v i2c-dev
{ lsmod | grep led-ugreen ; } || modprobe -v led-ugreen
i2c_dev=$(i2cdetect -l | grep "SMBus I801 adapter" | grep -Po "i2c-\d+")
if [ $? = 0 ]; then
echo "Found I2C device /dev/${i2c_dev}"
dev_path=/sys/bus/i2c/devices/$i2c_dev/${i2c_dev/i2c-/}-003a
if [ ! -d $dev_path ]; then
echo "led-ugreen 0x3a" > /sys/bus/i2c/devices/${i2c_dev}/new_device
elif [ "$(cat $dev_path/name)" != "led-ugreen" ]; then
echo "ERROR: the device ${i2c_dev/i2c-/}-003a has been registered as $(cat $dev_path/name)"
exit 1
fi
else
echo "I2C device not found!"
fi