<< Go back to Posts

MSI keyboard programming





Introduction

I bought a MSI laptop, where the keyboard is full of LEDs. Yet, I am using Linux, and there is no native support. So I searched to control it.

Get the Keyboard ID

lsusb

Among the output lines, I got:

Bus 001 Device 003: ID 1462:1601 Micro Star International MysticLight MS-1565

MysticLight MS-1565 is the name of the keyword.

So, now I have the reference, 1462:1601 or MysticLight MS-1565.

  • 1462 is the vendor ID (VID) of MSI (so not that interesting)
  • 1601 is the product ID (PID)

Mystic SDK

By searching “Mystic”, I found the official documentation.

MSI - Mystic - Download

But this is for Windows only …

Software for Linux

OpenRGB - Github Repo

At first, when I loaded the software, nothing appeared, no keyboard detected … I got a weird error, about i2c kernel stuff, that I needed to fix apparently.

I looked at the list of supported devices searching with my VID/PID

OpenRGB - List of supported devices

drawing

It took me some time to figure out that the name of the keyboard was registered, but not the PID/VID…

Running the software with sudo and reading the documentation helped to make the software run.

From GUI to CLI

The software help you to configure some effect, but it is very manual, even if you can save some config. I wanted to have a command line tool that let me configure with function the effect, not with a color picker.

I got recently a Claude subscription. I gave it the task to create a python wrapper that allows me to interact only with my keyboard (I am not interested with the other keyboards, I have a single computer).

Prompting Claude Code

This single prompt did the job:

Hello, this repo, openRGB allows to control keyboard lights on Linux. They support a wide range of keyboard. Mine is a MysticLight MS-1565, which is supported. I would like to       
  program the LEDs thanks to a python script, not a GUI. Therefore, I would like you to create a folder py_wrapper, where there, you create a class to interact with my keyboard,       
  and put all the necessary material there. This folder can be moved outside of here, to be reused alone. Please search the necessary element and implement a simple python class       
  to interact with 

It took me 5% of my 5 hours team credits to get a basic example running.

It created me 3 files:

  • one file with the constant
  • one file with the controler interface (the class which help interacting with the keboard)
  • one example file, a basic way for switching the colors of the leds.

Then, I asked a bunch of other stuff: create more effects, make the repo more organized, create a simulator (so I can test programming pattern while not being on my personal computer)

You can check the project on Github

Here is an output of the simulator.

Ocean Wave



>> You can subscribe to my mailing list here for a monthly update. <<