this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add ds4-leds

yemou fe4f1645 8f558972

+37
+37
scritps/ds4-leds
··· 1 + #!/bin/sh 2 + # Change the LEDs of a DualShock4 Controller 3 + 4 + usage() { 5 + printf '%s\n' "usage: ${0##*/} hex|rgb color" \ 6 + "${0##*/} accepts hex values (ffffff) or rgb values (255,255,255)" 7 + } 8 + 9 + [ "$2" ] || { usage; exit 1; } 10 + 11 + hex2rgb() { 12 + hex=$1 13 + hex_r=${hex%????} 14 + hex_g=${hex#??}; hex_g=${hex_g%??} 15 + hex_b=${hex#????} 16 + printf '%d,%d,%d' "0x$hex_r" "0x$hex_g" "0x$hex_b" 17 + } 18 + 19 + ds4leds() { 20 + vendorid="054C" 21 + productid="05C4" 22 + led_path="/sys/class/leds" 23 + 24 + IFS=, read -r rgb_r rgb_g rgb_b <<-EOF 25 + $1 26 + EOF 27 + 28 + printf '%s' "$rgb_r" | tee "$led_path/"*"$vendorid:$productid"*":red/brightness" > /dev/null 29 + printf '%s' "$rgb_g" | tee "$led_path/"*"$vendorid:$productid"*":green/brightness" > /dev/null 30 + printf '%s' "$rgb_b" | tee "$led_path/"*"$vendorid:$productid"*":blue/brightness" > /dev/null 31 + } 32 + 33 + case $1 in 34 + hex ) ds4leds "$(hex2rgb "$2")" ;; 35 + rgb ) ds4leds "$2" ;; 36 + *h|*help ) usage; exit 0 ;; 37 + esac