Skip to content
All work

Open Source, Linux Desktop App

G502 Hub, A G HUB Alternative for Linux

G502 Hub, A G HUB Alternative for Linux
Role
Author and maintainer
Timeline
Duration
Ongoing, six releases so far
Team
Solo, with two outside contributors
Stack
Python · PySide6 · HID++ 2.0 · Linux · Wayland · PipeWire · C

View the sourceVisit the siteRead the protocol referenceSee the releases

Overview

G502 Hub is an unofficial G HUB alternative for the Logitech G502 HERO on Linux. Logitech's own software doesn't run there, so the mouse's lighting, DPI levels, button layers and onboard profiles stay out of reach unless something speaks its protocol. G502 Hub does: no Windows, no Wine, no root.

I built it for my own desk, on EndeavourOS with KDE Plasma 6 on Wayland, and published it on 25 October 2026. It isn't a competition entry and there is no placement to report. What it has instead is users: more than 50 stars and 4 forks in its first five weeks, six releases, a Simplified Chinese translation and a performance fix sent by people I've never met, and an AUR package that one of them maintains.

The protocol work stands on other people's. libratbag, Solaar, cvuchener/hidpp, OpenRGB and the kernel's hid-logitech-hidpp driver had already mapped most of HID++ 2.0. I compiled their findings into one sourced reference, checked it against my own mouse, and built the app on top. It is an independent project, not affiliated with or endorsed by Logitech.

The problem

A gaming mouse keeps its settings in its own memory, and the official way to change them is a program that doesn't run on Linux. The open tools that exist cover parts of the job, and they can step on each other: ratbagd, for one, overwrites the mouse's G-Shift layer whenever it saves. Writing to a device's onboard memory also has to be right, because a wrong byte in a profile sector is a mouse that misbehaves on every computer it is plugged into. So the problem has two halves. Cover what G HUB covers, on a Wayland desktop where screen capture, the active window and synthetic input all work differently than they did on X11. And never leave the mouse in a state its owner can't get back from.

What I built

  1. 01

    Spoke HID++ 2.0 directly over hidraw

    No kernel module and no root: one udev rule lets the user talk to the mouse's vendor interface, and the app drives the features it needs, onboard profiles, adjustable DPI, report rate, colour LED effects and the button spy.

  2. 02

    Wrote the protocol down before writing to the mouse

    docs/protocol.md is a wire reference compiled from open reverse-engineering work, with every claim tagged by how it is known: probed on my own unit, seen in a published trace from the same USB ID, seen on a sibling model, read from source, or uncertain. A second file records what the real mouse actually does.

  3. 03

    Made every write safe to undo

    Before its first change in a session the app saves a full backup of the mouse's memory. It writes only the user profile area, never the factory profiles, reads every write back to check it, and keeps bytes it doesn't understand exactly as they were. Byte-exact round trips of real memory dumps are part of the tests.

  4. 04

    Covered the whole G HUB surface

    Up to five DPI levels from 100 to 25,600 with a sniper level, report rate up to 1000 Hz, all 11 buttons on the primary and G-Shift layers, macros recorded or built step by step, and the five onboard profile slots with export, import, backup and restore.

  5. 05

    Built live lighting on Wayland's own terms

    A screen sampler makes the mouse glow with whatever is on screen, through the desktop's screen-sharing portal and PipeWire, and an audio visualiser follows whatever is playing. Live effects only change the lights' RAM, so quitting brings the saved lighting straight back.

  6. 06

    Added rules for games and apps

    A rule fires when a Steam or Proton game is running, when an app is in front, which a tiny KWin script reports, when a window title matches, or when matching media is playing over MPRIS. YouTube playing turns the mouse red; a game can take its colours from its cover art.

  7. 07

    Let games drive the lights

    Counter-Strike 2 and Dota 2 report health, bomb timer and flashbangs through Valve's Game State Integration. For Windows games with built-in Logitech lighting, a small stand-in LogitechLed.dll written in freestanding C goes into the game's Proton prefix and forwards each call to the app. That bridge is experimental and says so.

  8. 08

    Shipped it like software people install

    A one-line installer that uses the distro's package manager and adds the udev rule and a menu entry, a PKGBUILD for Arch-based systems, a command line for everything the app does, and a daily update check that asks GitHub for the latest release and sends nothing else.

Architecture

01 · What is happening02 · The app03 · Device layer04 · Transport05 · HardwareKWin scriptactive windowMPRISplaying mediaSteam and Protonrunning gamesGame State IntegrationCS2 · Dota 2 · local HTTPLIGHTSYNC bridgeLogitechLed.dll · UDPPySide6 appstays in the trayCommand lineg502hub …Rules enginewhen … then …Live effectsscreen · audio · gameDevice featuresprofiles · DPI · rate · LEDsOnboard codecsprofile · binding · macroBackup and restorebefore the first writeHID++ 2.0over /dev/hidraw · no rootG502 HEROUSB 046d:c08b · 5 profiles

Three layers. At the bottom, a transport that frames HID++ 2.0 reports over /dev/hidraw. Above it, the device features and the codecs for the mouse's onboard memory: profiles, the directory, bindings, LEDs and macros, with backup and restore around them. On top, the PySide6 app and the command line share that device layer. Beside them a context service watches the desktop, the active window through KWin, media through MPRIS and running Steam games, and feeds the rules engine, which switches profiles and drives the live effects. Game lighting comes in from the side: Valve's Game State Integration posts to a local HTTP port, and the bridge DLL inside a Proton prefix sends UDP datagrams to localhost.

Tech stack

HID++ 2.0 transport

g502hub/hidpp.py talks to the wired G502 HERO (USB 046d:c08b, HID++ 4.2) on its vendor-specific interface. The kernel has no HID++ driver entry for this mouse, so nothing competes for the traffic.

Onboard memory codecs

16 sectors of 255 bytes, five user profiles in sectors 1 to 5, each with a CRC-16/CCITT-FALSE that is verified. Profile, directory, binding and LED codecs for format 2, and a separate codec for onboard macros.

Safety layer

A full dump before the first change of a session, writes confined to the user area, read-back after every write, unknown bytes preserved. It never uses the firmware's hidden factory or engineering features.

PySide6 app

A Qt 6 app that stays in the tray so rules, app-run macros and live lighting keep working with the window closed. English and Simplified Chinese, the second contributed by a user.

Live effects

Screen capture through the desktop portal and PipeWire, audio levels from a monitor source through parec, and the colour maths for wave, spectrum and DPI-colour effects. Screen and audio are analysed locally and nothing is sent anywhere.

Context and rules

Active window from a KWin script, playing media from MPRIS, and Steam and Proton games found automatically. On desktops other than KDE everything except active-window rules works.

Game integration

A local HTTP receiver for Valve's Game State Integration, and a LogitechLed.dll stand-in built with clang as freestanding C, which forwards a game's lighting calls to the app as UDP datagrams.

Tests and packaging

190 tests under pytest, run offscreen, with real memory dumps from the mouse as fixtures. An install script, an Arch PKGBUILD, and a landing page on Cloudflare.

Results

50+ stars

In the five weeks after it was published on 25 October 2026, with 4 forks. It is my most-starred repository.

6 releases

From 0.2.0 on 25 October to 0.5.0 on 30 November 2026. Two features in the latest one came from a user who emailed in with the ideas.

2 outside contributors

A Simplified Chinese translation with a language picker, and a fix that makes app-run macros react when a button changes instead of checking the mouse every 8 ms. The translator also maintains the AUR package.

190 tests

Including byte-exact round trips of real memory dumps, so a codec change that would alter one byte of a profile fails before it reaches a mouse.

Every write read back

And a full memory backup before the first change of each session, restorable from the Profiles page.

Moments

Games and apps: rules that change lighting and profile when a game starts, an app comes to the front, or matching media plays.
Games and apps: rules that change lighting and profile when a game starts, an app comes to the front, or matching media plays.
Sensitivity: up to five DPI levels on a draggable track, with a sniper level and the report rate.
Sensitivity: up to five DPI levels on a draggable track, with a sniper level and the report rate.
Assignments: all eleven buttons on the primary and G-Shift layers.
Assignments: all eleven buttons on the primary and G-Shift layers.
Profiles: the five onboard slots, with export, import, backup and restore.
Profiles: the five onboard slots, with export, import, backup and restore.

What I took away

  1. 01

    Sources first, then bytes. Tagging every protocol claim by how it is known meant I knew which bytes I could trust before sending any. Where an existing tool and my mouse disagreed about the current profile, it took a read-only probe to find out, not more reading.

  2. 02

    A device you write to deserves a backup you never have to think about. Making the dump automatic, before the first change of every session, turned a mistake from a broken mouse into a restore.

  3. 03

    Wayland isn't an obstacle, it is a different contract. Screen capture through the portal, the active window from a KWin script and popups through Plasma's own OSD each took longer than the X11 shortcut would have, and together they are why the app needs no root and no X11.

  4. 04

    Real users find what tests can't. The first issue was a mouse with a single profile slot enabled, which G HUB often leaves behind, and every save failed on it. The fix shipped three days after the first release.

  5. 05

    Open-source traction is a different signal from a jury's. Nobody had to be convinced in three minutes. People installed it, and two of them sent code back.

  6. 06

    Credit is part of the engineering. The protocol reference pins every source to a commit, and the notice file says plainly what belongs to Logitech and what the project is not.

View the sourceVisit the siteRead the protocol referenceSee the releases