I've bought a DualShock 4 controller and don't own a PlayStation 4 console. It's recognized on my ArchLinux systems out of the box. Newer kernels support it natively.
The sole issue is that by default, once it's connected to Bluetooth, it sets its LED to blue on full brightness. Besides the light being too strong, it reduces controller's battery time a lot.
Is there a way to configure a default brightness and/or color without additional and/or alternative drivers?
Best Answer
I've created a udev rule for this that works just fine. First it's needed to identify device attributes once the controller is connected, e.g.:
This will print a bunch of useful information that can be used to create a udev rule to match the device once it's connected, and execute something.
Here, I've picked
ATTRS{uniq}
to indentify my controller in specific (one can also use a more general DualShock 4 match, pickingATTRS{name}=="Wireless Controller"
for example):/etc/udev/rules.d/10-local.rules
It's possible to control LED brightness and color by writing RGB values to paths similar to the following:
The above sets my controller's blue component to maximum brightness. The
0005:054C:09CC.000B
part of the path may vary per connection.The previous udev rule executes the following script, which accepts two arguments, a path that contains a pattern like
0005:054C:09CC.000B
, which it extracts to build the/sys/class/leds/0005:054C:09CC.000B:blue/brightness
path, and a color in the RRGGBB form:/usr/local/bin/ds4led
(do not forget to set executable permission for this)ds4led
can both be called manually likesudo ds4led /sys/class/leds/0005:054C:09CC.000B:global 0000FF
or from a udev rule by passing%p
as the first argument. Even though udev will pass adevpath
that's completely different from/sys/class/leds/...
, it'll still contain a pattern like0005:054C:09CC.000B
in it.