alpha
Login
or
Join now
yemou.pink
/
scripts
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
ds4-leds: remove
author
yemou
date
2 years ago
(Jan 6, 2024, 4:05 PM -0500)
commit
d75a55d3
d75a55d39ee58bc97f41c909a790c01b9d54629b
parent
a2790a0a
a2790a0a38f04e76f6dafb862baa7b74502762fc
-42
1 changed file
Expand all
Collapse all
Unified
Split
scritps
ds4-leds
-42
scritps/ds4-leds
Reviewed
···
1
1
-
#!/bin/sh
2
2
-
# Change the LEDs of a DualShock4 Controller
3
3
-
4
4
-
usage() {
5
5
-
printf '%s\n' "usage: ${0##*/} hex|rgb color" \
6
6
-
"${0##*/} accepts hex values (ffffff) or rgb values (255,255,255)"
7
7
-
}
8
8
-
9
9
-
[ "$2" ] || { usage; exit 1; }
10
10
-
11
11
-
hex2rgb() {
12
12
-
hex=$1
13
13
-
hex_r=${hex%????}
14
14
-
hex_g=${hex#??}; hex_g=${hex_g%??}
15
15
-
hex_b=${hex#????}
16
16
-
17
17
-
printf '%d,%d,%d' "0x$hex_r" "0x$hex_g" "0x$hex_b"
18
18
-
}
19
19
-
20
20
-
ds4leds() {
21
21
-
vendorid="054C"
22
22
-
led_path="/sys/class/leds"
23
23
-
24
24
-
case $led_path/* in
25
25
-
"$led_path/"*"$vendorid:05C4"*":global" ) productid="05C4" ;;
26
26
-
"$led_path/"*"$vendorid:0BA0"*":global" ) productid="0BA0" ;;
27
27
-
esac
28
28
-
29
29
-
IFS=, read -r r g b <<-EOF
30
30
-
$1
31
31
-
EOF
32
32
-
33
33
-
printf '%s' "$r" | tee "$led_path/"*"$vendorid:$productid"*":red/brightness" > /dev/null
34
34
-
printf '%s' "$g" | tee "$led_path/"*"$vendorid:$productid"*":green/brightness" > /dev/null
35
35
-
printf '%s' "$b" | tee "$led_path/"*"$vendorid:$productid"*":blue/brightness" > /dev/null
36
36
-
}
37
37
-
38
38
-
case $1 in
39
39
-
hex ) ds4leds "$(hex2rgb "$2")" ;;
40
40
-
rgb ) ds4leds "$2" ;;
41
41
-
*h|*help ) usage; exit 0 ;;
42
42
-
esac