This works, thanks! Is there anyway to set the led brightness too?
Just use darker colours.
The three numbers are the RGB components (red, green, blue) in hexadecimal, and each number goes from 0 to 255 intensity (but note that instead of RGB it reads BGR, and instead of using decimal numbers it reads hexadecimal values). So â0 0 FFâ means no Blue, no Green and Red at full intensity.
I love being able to change the keyboard color to amber from the command line withâŚ
printf 'xLRGB\x00\x11\x30' | sudo tee /dev/hidraw0
Iâve been trying to get the same effect via a cron job by adding the code below to my su crontab and have been getting mixed results
@reboot sleep 30 && test -c /dev/hidraw0 && printf 'xLRGB\x00\x11\x30' > /dev/hidraw0
If I use double quotation marks on either side of the xLRGB portion it doesnât work.
If I use single quotation marks on either side of the xLRGB portion it works, but only changes the keyboard color to cyan no matter the value Iâve added.
Anyone have an idea as to why this may be happening?
Try to specify the path for printf, so you are not using any shell builtin, use /usr/bin/printf instead of printf.
Bingo! That did it. Thanks a million!
For future reference to anyone else, the code below is what worked for in my su crontab. Change the sleep value and the RGB values to whatever you desire.
@reboot sleep 10 && test -c /dev/hidraw0 && /usr/bin/printf 'xLRGB\x00\x11\x30' > /dev/hidraw0
I may need to move this to a new thread. I have been playing with the firmware of the keyboard and I think we could edit the firmware to have the default config unless a file is present. If âFileâ is present the basic color, brightness and timeout for the backlight could be adjusted and polled by the firmware for changes. Would anyone else be interested in these changes?
Sounds good. I have a script to update mine when I update my wallpaper (using imagemagick to determine a predominant colour, and to change the brightness & saturation) - just not quite happy enough with how itâs working to share it yet.
Iâve been trying the approach with the different approaches from this thread:
(trying pure red to make the effect really obvious)
test -c /dev/hidraw0 && printf "xLRGB\x00\x00\xFF" > /dev/hidraw0
and
printf 'xLRGB\x00\x00\xFF' | tee /dev/hidraw0
When run from a root shell, both work as expected, but when run from rootâs crontab with @reboot
(with additional sleep and without) it always turns the light to a mid-brightness white.
Any ideas why?
EDIT:
Nevermind, I wasnât using absolute paths for /usr/bin/printf
as described earlier in this thread. That does the trick. Sorry
Man, I now want to make the backlight go red when I am running something as the root user, and back to whatever Iâd set it previously when I drop back to my user permissions⌠(not for every sudo
invocation, just when i was in a root shell â this seems very doable)
I quickly hacked something together for this at uni today:
Ă.: "Neat little MNT Pocket Reform hack: When I launcâŚ" - The Wandering Shop (Mastodon post with demo video)
I used rootâs .bashrc
and .bash_logout
to trigger the color changes when launching and closing a root shell.
Itâs not perfect because itâll return to green when you exit one root shell regardless of whether other root shells are still open. But tbh when you have multiple root shells open at the same time, something else has gone very wrong already