I made a post here about how I solved the problems I was experiencing with msiklm and how my hardware/OS was causing me... troubles.
It seems that with the recent updates to Debian/Ubuntu/Mint and the Kernel (6.5+) I was experiencing a re-occurrence of all sorts of trauma.
SO! I resolved to learn a bit about Services (enough to be dangerous) and found a solution that works (for now). I wanted to share it to the Borg Collective so all may use it, or someone may correct my ignorance. :)
ISSUES
msiklm would not start reliably with any sort of autostart routine
I tried everything I could think of. I went down many rabbit holes.
One of the big troubles was a "race condition" where the lights flickered, the scripts fired continuously or they simply failed to execute upon waking. They would work, until they did not. The mysteriousness was high.
I do NOT believe that this is a msiklm thing, but a collection of unfortunate bugs in various systems that it relies upon, and it in no way the fault of the program or the way it is implemented. I believe, simply, that MSI and the USB keyboard lighting is ... well... fucked.
THE FIX
These notes discuss the fix, that works so far.
For those who wish to explore other methods, please do read my earlier post. It worked for me, for a while, until it didn't. YMMV.
MY SETUP
MSI GP62M 7REX v: REV:1.0
Kernel: 6.5.0-15-generic x86_64
Cinnamon 6.0.4, updated fully
Using the Gnome LightDM desktop and NOT the experimental Wayland.
This is my Pastebin (sudo inxi -Fzxxx | pastebin) for those who want to see what hardware I'm using.
# this file belongs in /etc/sudoers.d/extraPermissions
# it must be root/root
# it must be 440
yourusername ALL=(ALL:ALL) NOPASSWD: /usr/local/bin/msiklm
Save it (CTRL-O) and exit (CTRL-x) and now set the file to be read only:
$ sudo chmod 440 /etc/sudoers.d/extraPermissions
PART 2 - MAKING A SERVICE FILE TO RUN MSIKLM
Create a systemd service unit file:
$ sudo touch /etc/systemd/system/msiklm.service
Open a terminal and create a new service unit file using a text editor like nano. For example:
$ sudo nano /etc/systemd/system/msiklm.service
Copy this in. Save and exit the editor.
[Unit]
Description=MSIKLM Service Green
After=network.target
[Service]
ExecStart=sudo /usr/local/bin/msiklm green
Restart=always
RestartSec=10
User=yourusername
[Install]
WantedBy=default.target
WantedBy=sleep.target
WantedBy=systemd-suspend.service
WantedBy=systemd-hibernate.service
Make sure to replace yourusername with the actual username under which you want to run the service.
Change the ExecStart appellation to the colourations ye wish, as if it were run from the terminal. Here I choose green as I like radioactivity :)
This is novel for me. All errors are mine. I am new to services under systemd. I am an old Linux user and still think in "init". I have to admit that systemd is pretty damned cool.
Happy to answer any questions, but I absolutely do not wish to steal the thunder of @Gibtnix
I set the RestartSec= to 10 in the .service file as a start point. This feature simply executes the command to run every 10 seconds (fairly obvious!) but could probably be set to something more lengthy, say 60 or whatever is sane.
I monitored the effect of this on the CPU via htop for ages and dumped out the process usage for review. It has a non-existent effect on CPU that I can tell.
The logs do get flooded, see dmesg. When the service fires it shotguns all kinds of crap into it. Ignore it.
To see the script work, simply set thy keyboard to another colour via (e.g.) $sudo msiklm orange and it will magically change as the service runs :)
ENJOY :)
(Edit 10June2024 - fixed the msiklm.service name. I made a boo boo)
Greetings fans of msiklm.
I made a post here about how I solved the problems I was experiencing with msiklm and how my hardware/OS was causing me... troubles.
It seems that with the recent updates to Debian/Ubuntu/Mint and the Kernel (6.5+) I was experiencing a re-occurrence of all sorts of trauma.
SO! I resolved to learn a bit about Services (enough to be dangerous) and found a solution that works (for now). I wanted to share it to the Borg Collective so all may use it, or someone may correct my ignorance. :)
ISSUES
THE FIX
These notes discuss the fix, that works so far.
For those who wish to explore other methods, please do read my earlier post. It worked for me, for a while, until it didn't. YMMV.
MY SETUP
MSI GP62M 7REX v: REV:1.0 Kernel: 6.5.0-15-generic x86_64 Cinnamon 6.0.4, updated fully Using the Gnome LightDM desktop and NOT the experimental Wayland. This is my Pastebin (
sudo inxi -Fzxxx | pastebin
) for those who want to see what hardware I'm using.PART 1 - ADDING MSIKLM TO SUDOERS
Add these lines to the file:
Save it (CTRL-O) and exit (CTRL-x) and now set the file to be read only:
$ sudo chmod 440 /etc/sudoers.d/extraPermissions
PART 2 - MAKING A SERVICE FILE TO RUN MSIKLM
Create a systemd service unit file:
$ sudo touch /etc/systemd/system/msiklm.service
Open a terminal and create a new service unit file using a text editor like nano. For example:
$ sudo nano /etc/systemd/system/msiklm.service
Copy this in. Save and exit the editor.
yourusername
with the actual username under which you want to run the service.ExecStart
appellation to the colourations ye wish, as if it were run from the terminal. Here I choosegreen
as I like radioactivity :)Now, to get it working:
NOTES
RestartSec=
to 10 in the.service
file as a start point. This feature simply executes the command to run every 10 seconds (fairly obvious!) but could probably be set to something more lengthy, say 60 or whatever is sane.htop
for ages and dumped out the process usage for review. It has a non-existent effect on CPU that I can tell.dmesg
. When the service fires it shotguns all kinds of crap into it. Ignore it.$sudo msiklm orange
and it will magically change as the service runs :)ENJOY :)
(Edit 10June2024 - fixed the msiklm.service name. I made a boo boo)