How to make the pairing of the ‘ltunify’ program permanent

hardwarekeyboardmouse

I have used the ltunify pairing tool for Logitech Unifying Receiver, written by Lekensteyn, on my Logitech M510 mouse and K350 keyboard, which works perfectly. However, when I reboot, these changes are lost and I have to plug in an old keyboard so that I can re-run ltunify.

Is there any way to make these changes permanent so that I don't have to keep switching my devices on and off each time I reboot?

EDIT: After rebooting the machine and executing ltunify list, it shows that the devices ARE connected and paired, despite the fact that they are not working:

    Devices count: 2
    Connected devices:
    idx=1   Mouse   M510
    idx=2   Keyboard    K350

Note also, that:

  • In the BIOS, both the keyboard and mouse work out-of-the-box
  • In the GRUB boot menu, the keyboard works (cannot test the mouse, as it's not a GUI)
  • In the installer (CentOS 7) both the keyboard and mouse work out-of-the-box
  • CentOS 7 64-bit with kernel 3.10.0-123.20.1.el7.x86_64

EDIT2: The system I'm using is an Intel NUC DN2820HKFY.

Best Answer

As you have mentioned, the device have not really lost their pairing state so that should rule out hardware defects.

The most likely issue I can think of is the presence of runtime power management that somehow makes the USB port sleep and thus be unaware of the receiver. Clicking with the mouse or pressing a key should however solve such issues.

Suggestions that are worth trying:

  • Plug the Logitech Unifying receiver in a different USB port. Older kernels had issues with USB 3.0 and the receiver where USB 2.0 would work. (In kernels released in the past two years, I had no such issues though.)
  • Disable power management for the USB port.
  • Re-insert the USB receiver when the problem occurs.

In the past, I have written this udev rules file to trigger the pairing process upon receiver insertion. Adjust the ltunify and timeout values and place them in /etc/udev/rules.d/60-ltunify-pair.rules.

# skip actual unified devices, only consider the receiver
DRIVERS=="logitech-djdevice", GOTO="do_not_pair"
# ignore devices in Linux 3.19+
DRIVERS=="logitech-hidpp", GOTO="do_not_pair"

# Skip removal, pairing makes no sense
ACTION!="add", GOTO="do_not_pair"
SUBSYSTEM!="hidraw", GOTO="do_not_pair"

# official Unifying receivers
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52b", GOTO="do_pair"
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c532", GOTO="do_pair"

# "Unifying Ready" Nano receiver
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52f", GOTO="do_pair"

GOTO="do_not_pair"

LABEL="do_pair"
# 5 seconds to pair a new device
PROGRAM="/bin/sh -c 'sleep .5; /usr/local/bin/ltunify pair 5'"

LABEL="do_not_pair"
# vim: ft=udevrules
Related Question