Gibtnix / MSIKLM

Control the SteelSeries keyboard of your MSI gaming notebook with Linux
GNU General Public License v3.0
244 stars 50 forks source link

INFO: Servicifying msiklm to fix wakeup and other race conditions #54

Open AtomicRobotMan0101 opened 9 months ago

AtomicRobotMan0101 commented 9 months ago

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

$ sudo touch /etc/sudoers.d/extraPermissions
$ sudo nano /etc/sudoers.d/extraPermissions

Add these lines to the file:

# 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

Now, to get it working:

sudo systemctl daemon-reload
sudo systemctl enable msiklm.service
sudo systemctl start msiklm.service

NOTES

ENJOY :)

(Edit 10June2024 - fixed the msiklm.service name. I made a boo boo)

Gibtnix commented 9 months ago

Thanks for your work, hope it helps fixing autostart issues 👍