Skip to content

logid misses MX Master 3S at boot (UHID/hidraw race); udev restart-on-add fixes it #522

@aydiler

Description

@aydiler

Environment

  • Distro: CachyOS (Arch) x86_64
  • Kernel: 6.17.1-2-cachyos
  • Desktop: KDE Plasma 6.4.5 (Wayland), KWin
  • Device: Logitech MX Master 3S (Bluetooth, UHID 0005:046D:B034)
  • BlueZ: 5.84-1.1
  • logiops/logid: 0.3.5-1

Summary

At boot, logid starts before the Bluetooth UHID/hidraw device is ready. It tries 5 times, gives up, and won’t re-scan that node. Later, when the hidraw is (re)added, logid only works after a restart.

Steps to Reproduce

  1. Boot into Wayland session (KDE/Sway likely similar).

  2. MX Master 3S is paired via Bluetooth (not using USB receiver).

  3. journalctl -b -u logid shows:

    [WARN] Failed to add device /dev/hidraw14 after 5 tries. Treating as failure.
    
  4. Toggling the mouse off/on produces a new UHID path .../uhid/0005:046D:B034.xxxx/.../hidraw14, but logid does not apply settings until the service is restarted.

Expected

logid should pick up the mouse as soon as its hidraw appears and apply settings without manual restart.

Actual logs (examples)

Okt 17 20:12:36 logid[1019]: [WARN] Failed to add device /dev/hidraw14 after 5 tries. Treating as failure.
...
Okt 17 20:13:09 logid[1019]: [INFO] Device found: MX Master 3S on /dev/hidraw14:255

Workarounds that make it reliable

Either of the following fixes the timing/race:

A) Restart logid on every hidraw add/change (covers early-boot too)
/etc/udev/rules.d/90-logid-start-restart.rules

# Logitech via USB receiver
ACTION=="add|change", SUBSYSTEM=="hidraw", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", \
  RUN+="/usr/bin/systemctl restart --no-block logid.service"

# Logitech via Bluetooth (BlueZ UHID path 0005:046D:...)
ACTION=="add|change", SUBSYSTEM=="hidraw", KERNELS=="0005:046D:*", \
  RUN+="/usr/bin/systemctl restart --no-block logid.service"

(Optional) one-shot timer to nudge after boot:

# /etc/systemd/system/logid-postboot.service
[Unit]
Description=Post-boot nudge for logid
After=bluetooth.service
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart logid.service
# /etc/systemd/system/logid-postboot.timer
[Unit]
Description=Run logid restart 15s after boot
[Timer]
OnBootSec=15s
Unit=logid-postboot.service
[Install]
WantedBy=timers.target

B) Start logid on-demand (alternative)
Instead of RUN+=restart, use:

ACTION=="add|change", SUBSYSTEM=="hidraw", KERNELS=="0005:046D:*", \
  TAG+="systemd", ENV{SYSTEMD_WANTS}+="logid.service"
ACTION=="add|change", SUBSYSTEM=="hidraw", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", \
  TAG+="systemd", ENV{SYSTEMD_WANTS}+="logid.service"

…and keep logid.service disabled at boot. (This worked but still hit rare early-boot cases, hence A + small timer is bullet-proof.)

Service drop-in (minimal)

# /etc/systemd/system/logid.service.d/override.conf
[Unit]
After=
After=bluetooth.service bluetooth.target systemd-udev-settle.service
Wants=bluetooth.service bluetooth.target systemd-udev-settle.service

[Service]
ExecStartPre=
Restart=on-failure
RestartSec=2s

Proposed remedies upstream

  • Ship a udev rule in contrib/ (or enabled by default) to restart on hidraw add/change for Logitech BT/USB.
  • Or make logid watch udev and rescan on new hidraw nodes instead of giving up after 5 attempts.
  • Relax unit ordering to avoid starting before BT/uhid is ready (e.g., After=bluetooth.service), though event-based is more robust.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions