I love hardware, and I love peripherals most of all. I care more about my keyboard and mouse than about the computer itself, because they are what I interact with all day. I enjoy the feel of a good switch, the weight of a mouse in my hand and the glow of a keyboard in a dark room.
I especially love low profile mechanical keyboards. They have the crisp feel of real switches, but the keys sit low and flat, so my hands stay relaxed. For years my desk was ruled by Sharkoon. I have a Sharkoon PureWriter TKL keyboard with low profile Kailh red switches that went for about 60 euro and a Sharkoon Shark Force II mouse that goes for about 15 euro, and I was very happy with both. They do exactly what I ask of them for very little money, and they do not rely on any software: you set the lighting on the device itself and it just stays that way, on any operating system. I never thought I would want to find a replacement for them, but the PureWriter TKL has been discontinued.
Normally I do not consider Logitech, because their Linux support is absent. But I had heard nice things about the G515 TKL keyboard and the G502 HERO mouse, the prices were not awful and I found some open source projects that made me hopeful. So I recently started using them on my Linux Mint XFCE desktop machine. Both are great devices although they cost more than their Sharkoon equivalents. They come with RGB lighting that Logitech wants you to configure with G HUB, and G HUB does not run on Linux. Instead of installing these tools in a Windows VM to support my hardware, I wrote a Linux tool that sets the lighting of both devices: logirgb. Claude, the documentation of Logitech and other open source implementations helped me to achieve this.
See: https://github.com/mevdschee/logirgb
The G515 TKL keyboard
The G515 TKL is a low profile mechanical keyboard without a numeric keypad. I
use the wired version (USB ID 046d:c358). There is also a more expensive
LIGHTSPEED version that works wireless, but I see little benefit in it for a
keyboard that stays on my desk. The keyboard has per key RGB lighting and a
firmware that can dim the lighting after a while and switch it off when you are
away.
I wanted a single calm color that dims when I am not typing, and I wanted that to work after a reboot without any software running.
The G502 HERO mouse
The G502 HERO (mine is the G502 SE HERO, USB ID 046d:c08b) is a wired gaming
mouse with a lot of buttons, a heavy scroll wheel and a sensor that goes from
100 to 25600 DPI. It has two lighting zones: the G logo on the palm rest and the
DPI indicator LEDs on the side. Those DPI LEDs only light up for a moment when
you press a DPI button. The mouse stores five onboard profiles, and each profile
has its own lighting, DPI levels and report rate. You switch profiles with the
button behind the scroll wheel.
I wanted the logo to show one color, and I wanted it to stay that color when I switch profiles or replug the mouse.
Why another tool?
On Linux there are several projects that can talk to Logitech devices. Solaar is great for wireless devices on a Unifying or LIGHTSPEED receiver, libratbag (with the Piper GUI) handles mice, OpenRGB tries to control all RGB hardware in your machine and g810-led supports older Logitech keyboards. None of them covered both of my devices in the way I wanted. The G515 uses the newer 0x8071 lighting feature and stores its settings with the 0x8101 profile management feature, which most tools did not support for this keyboard. Most tools also control the lighting from the host, which means a process has to keep running and the keyboard does not dim by itself.
Like the Onboard Memory Manager
Logitech has a small alternative to G HUB called the Onboard Memory Manager (OMM). It lets you view and change the onboard memory of a compatible Logitech G mouse, such as the DPI levels and the lighting. The settings are stored in the mouse itself, so they keep working on any computer without software running. Unfortunately OMM only runs on Windows and only supports mice. logirgb works like it: it reads the onboard memory of the device, lets you change it and writes it back. But it runs on Linux and it also supports the G515 keyboard.
What logirgb does
logirgb is written in Go and talks the HID++ 2.0 protocol directly over
/dev/hidraw. It does not need G HUB, Solaar, OpenRGB or libusb. It finds the
devices by scanning /sys/class/hidraw for Logitech nodes that declare the
HID++ long report. You install it with:
go install github.com/mevdschee/logirgb/cmd/logirgb@latest
The hidraw nodes are usually only accessible to root. logirgb checks this when it starts and prints the commands to fix it. It can also print a udev rule that gives the logged in user access to Logitech hidraw devices:
logirgb udev-rule | sudo tee /etc/udev/rules.d/70-logirgb.rules >/dev/null
When you run logirgb without arguments you get a terminal UI. On the left you
pick a device and on the right you change the effect, the colors, the brightness
and the timeouts. Changes show on the device immediately, so you can try colors
with the arrow keys, and w stores them. There is also a CLI for scripts:
logirgb list
logirgb set static --color orange
logirgb set -d g515 breathe --color blue --period 3000
logirgb timeouts -d g515 --idle 60 --sleep 300 --dim 50
logirgb set -d g515 static --color red --preview
The supported effects are off, static, pulse, breathe, cycle, wave, ripple and
starlight, and logirgb list shows which effects each zone supports.
Storing the lighting in the device
The most important feature for me is that the settings are stored in the device.
There is no config file, the onboard memory of the device is the source of
truth. logirgb reads the lighting and timeouts from it and writes changes back
to it. set and timeouts store their change right away, unless you pass
--preview, and in the TUI w stores what you see. Every write is verified by
reading it back.
The G515 can dim and turn off its lighting in the firmware, so I leveraged that. logirgb stores the lighting and the idle and sleep timeouts in the keyboard, and nothing has to run on the computer.
The G502 also stores its lighting in onboard memory, but it has five onboard
profiles that you switch with the button behind the scroll wheel, and each
profile has its own lighting. logirgb writes the lighting into one profile at a
time, so you choose which profile you want to change: with the Profile row in
the TUI or with set -p <n>, and without -p it changes the active profile. If
the mouse still runs its factory profiles, they are copied to the user profile
sectors with only the LED blocks changed, so DPI, buttons and report rate stay
the same. The TUI also lets you edit the DPI levels and the report rate of each
profile. You can disable profiles you do not use, so the profile button skips
them:
logirgb profiles -d g502 --disable 3,4,5
logirgb reset-profiles -d g502 takes the mouse back to its factory profiles.
Research notes
Logitech published documents for many of the HID++ 2.0 features, such as 0x8040
(brightness), 0x8070 and 0x8071 (lighting effects), and these were the starting
point for Claude and me. A copy of them is included in the repository. There is
no public documentation for the onboard profile features 0x8100 and 0x8101. For
those Claude read the source code of Solaar, OpenRGB, libratbag and
logitech-g515-onboard,
and I tested everything on my own devices. I’ve put the notes in the research
folder of the repository. They contain a hardware log with every request and
reply I tried, a catalog of the G5xx devices with their USB IDs and features and
notes per HID++ feature. Every claim is marked with where it comes from: the
Logitech spec, my hardware, the source of a tool or unverified. I hope these
notes are useful for people who want to add support for these devices to other
tools.
Library
The protocol code can be used on its own. The hidpp package does the
discovery, the request and response matching and the feature lookup. The
lighting package handles the zones, effects, brightness, idle timers and
storing the lighting in onboard memory:
infos, _ := hidpp.Discover()
dev, _ := hidpp.Open(infos[0])
defer dev.Close()
ctl, _ := lighting.New(dev)
ctl.Claim()
ctl.SetEffect(0, lighting.Effect{Name: "static", Values: map[lighting.Param]int{lighting.ParamColor: 0xff8000}})
Future work: other devices
I tested logirgb on the G515 TKL and the G502 HERO, as those are the devices I own. Other devices that expose the 0x8070 or 0x8071 lighting features should work too, such as the G502 Proteus Spectrum, the G502 X PLUS or the G513. If you own one of these and it works (or it does not), please open an issue on GitHub.
NB: Logitech, if you are reading this: I’m happy to add support for the entire G device series, just ship me the devices and I’ll make their Linux experience awseome!
Enjoy!
Links
- GitHub.com - mevdschee/logirgb
- Logi.com - Onboard Memory Manager
- LinuxVox.com - Logitech G Hub on Linux: A Comprehensive Guide
- GitHub.com - pwr-Solaar/Solaar
- GitLab.com - CalcProgrammer1/OpenRGB
- GitHub.com - libratbag/libratbag
- GitHub.com - federico-duppa/logitech-g515-onboard
- Google Drive - Logitech HID++ 2.0 feature documents