Unifying Logitech Devices on Linux

I was recently given a Logitech K800 keyboard and a Logitech Performance Mouse MX, both of which are great devices. I picked them because wireless-ness is useful for ergonomic reasons, and they have rechargeable batteries, and you can attach them both to the same USB input, so you have fewer cables lying around.

Naturally, though, when I unboxed them I found out that you can only unify them to the same receiver with Windows-only software. There are a number of other features that are only usable with the Windows-only software, but I figured there would be a hardware sync process. Unfortunately, there's not a Logitech supported one.

There is, however, a community developed one! There's a short C program with a bunch of magic numbers which send commands to the device and cause it to unify with a new device. Unfortunately, the program comes with no directions, so I thought I'd post about how to do it. First, put the program in pairing_tool.c, as suggested in the post. Then, compile it with:

gcc -o pairing_tool pairing_tool.c

To run it, we need to figure out where the Logitech unifying receiver is. The program wants the hidraw device corresponding to the unifying receiver. To find this out, you can look in /sys/class/hidraw/hidraw*/device/uevent. In my case, the device is hidraw2, and the output looks like this:

smitten:~$ cat /sys/class/hidraw/hidraw2/device/uevent 
HID_NAME=Logitech USB Receiver

So, we can now unify the devices with the following command:

sudo ./pairing_tool /dev/hidraw2

And then power on your device as the tool tells you to. I think there's some timeout on this, because the first time I did it I waited a few minutes and then powered on the device, and it didn't work. So, have your device ready and do it seconds after you run the pairing tool, and it should all work fine. HTH!


ding at 2011-12-30 10:06:42 UTC:

That's cool! So, this doesn't require any kernel patches for the extra mouse buttons? The mailing list thread you've linked to contains kernel patches in the first thread.

tycho at 2012-01-12 21:48:31 UTC:

Nope, it doesn't (at least, not on my xubuntu kernel); I'd say the patch was already accepted. Just run the pairing tool and you're good to go.

Pavel at 2012-01-25 20:06:07 UTC:

Thanks man. Really helped me out. In my case I was not able to find hiddraw device so I run the tool on all of them. Last one worked.

Tehas at 2012-01-28 02:18:29 UTC:

I didn't have luck looking through the uevent files. Instead, I went through the output from 'dmesg'. I plugged in the USB receiver and then ran dmesg | less. The last set of messages in the output indicated that I needed to use /dev/hidraw2. Thanks for documenting this.

demon at 2012-01-31 22:41:37 UTC:

@ding: Looks like the patch at the start of the thread has to do with allowing individual keyboards and mice attached via a Unifying receiver to appear to the kernel as separate HID devices. Looks like this utility should work without it, just multiple devices' events would show up via the same mouse/keyboard device node. (I wanted to get a Performance MX mouse, but I was hoping to get the Bluetooth version; looks like that isn't gonna happen, but this means that I can at least use the "Unifying" receiver as intended.)

Aaron Lippold at 2012-02-28 01:25:23 UTC:

Kudos to you! Thanks for writing up a great little howto. I was about to embark on this myself after finding a link to the program on the linux.kernel list on Google but then saw your page a few results down. I guess a little gui would be the next thing. Maybe I can see about working that. A

from_finland at 2012-02-28 17:58:31 UTC:

Thanks for the tip and software. Worked for me with first try running the software without even restarting keyboard many times. ansi-c compiled without any problems with gcc x86_64 as it should.

Gary Heard at 2012-03-14 11:41:27 UTC:

Thank you for clear concise instructions. Worked brilliantly

primos at 2012-04-15 01:34:04 UTC:

Brilliant!!! Linux Mint 12 and about 1 min worth of my time :) and Logitech cannot do this because?????? Thanks for instructions!!

clach04 at 2012-04-15 19:17:59 UTC:

I've collected a few tools for doing this at https://bitbucket.org/clach04/logitech-unifying-receiver-tools it includes the C one used above as well as a portable python version that should work on a Mac with PyUSB and libusb.

Peter at 2012-04-18 04:19:21 UTC:

I just tried these instructions (on Ubuntu 10.04), and got the following error message: Error: 32 write: Broken pipe Any thoughts on why this is?

neversetsun at 2012-04-26 16:19:19 UTC:

I tried to connect 2 M215 to the same unifying receiver using this userspace tool with 3.0.0-17 of ubuntu 11.10. But I failed. The kernel shipped with 11.10 doesn't have hid-logitech-dj.c, is this driver also needed?

tycho at 2012-04-28 21:01:47 UTC:

Hmm, it worked just fine for me on 11.10, so I'm not sure what to tell you. How did it fail?

pink-panther at 2012-04-29 10:25:52 UTC:

Thank you, it worked on Ubuntu 11.10.

Mantrid at 2012-05-02 00:03:36 UTC:

Works with openSUSE 12.1

Mark at 2012-05-02 10:49:50 UTC:

Thank you!

al at 2012-05-09 03:55:47 UTC:

posted your solution to the boards at Logitech http://forums.logitech.com/t5/Mice-and-Pointing-Devices/Unifying-and-linux/m-p/831753#M39963 adios, @

reverbel at 2012-05-12 16:23:15 UTC:

Worked like a charm on Ubuntu 12.04! Thank you!

pjokinen at 2012-05-24 15:41:53 UTC:

WOW Better tool than Logitech owns ever :)

pjokinen at 2012-05-24 15:47:04 UTC:

And i use: Debian “wheezy" 64-bit Kernel 3.2.0-2-amd64 Gnome 3.4.2

jeffjones72 at 2012-05-30 00:17:44 UTC:

Tried this and get an error. write: 0 were written instead of 7. write: Cannot allocate memory Any ideas?

jeffjones72 at 2012-05-30 00:19:24 UTC:

Ubuntu 12.04 64-bit

tycho at 2012-06-04 21:53:25 UTC:

jeffjones72: sounds to me like it might be a permissions problem (the ENOMEM is likely a red herring, unless your system was swapping heavily at the time). Are you running it as root?

K at 2012-07-07 09:19:42 UTC:

jeffjones72: hi, I had your same problem, I'm also on Ubuntu 12.04 64bit Did "sudo ./pairing_tool /dev/hidraw0" instead of "sudo ./pairing_tool /dev/hidraw2" and now it works. On "cat /sys/class/hidraw/hidraw2/device/uevent" it told me "HID_NAME=Logitech Unifying Device. Wireless PID:1028", while on "cat /sys/class/hidraw/hidraw0/device/uevent" it told me "HID_NAME=Logitech USB Receiver" Hope this helps K.

Mektub at 2012-07-11 01:09:59 UTC:

Works for me on Archlinux (rollig release) Great! Mektub

Jack at 2012-07-19 19:04:51 UTC:

Error 32 broken pipe on a 2.6.32-1-mepis-smp, i686 (squeeze/sid) system. It's mostly a stock Mepis 8.5 system, with some manually installed packages from sid, and some of the other non-traditional repos, but only when I have an actual unifying receiver plugged in. I will test this software on a different distro, same machine later. Mepis is the Corporate Production Desktop. I have an alternate boot image for a newer Mint release. I will also try this on my Wheezy Raspbian powered RPi later.

Jack at 2012-07-20 01:42:19 UTC:

Update: works in Linux Mint, same box, running an x86 64 bit 3.0 kernel (Ubuntu based). I did get broken pipes when trying to pair on the wrong HID device.

Ran Talbott at 2012-08-06 20:56:40 UTC:

Ubuntu 10.04 shows the Logitech receiver (already paired with a keyboard) as 3 different devices: hidraw0, 1, and 2. Fails with error 32 (broken pipe) on all 3. My guess is that the kernel (2.6.32-37) isn't recent enough.

Graphite at 2012-08-11 15:18:46 UTC:

write: 0 were written instead of 7. write: Cannot allocate memory Any ideas? I observed this error when I passed the wrong hidraw device as a parameter. Double check that the right hidraw device was entered.

mib at 2012-09-09 13:54:19 UTC:

Works great - thank you :)(debian wheezy)

sxj at 2012-09-19 10:31:57 UTC:

followed the steps, but a look at the path /sys/class/hidraw/ it is empty. any idea what could be wrong

jay at 2012-09-22 13:45:33 UTC:

I don't have anything /sys/class/hidraw/ directory either. I am running ubuntu 12.04.1 kernel 3.2.30

tom at 2012-09-22 15:39:24 UTC:

I was able to pair my logitech mouse and keyboard, but after reboot, I lost them again. OS: Ubuntu 12.04

igli at 2012-10-03 22:18:09 UTC:

You could call this from an initscript. Hopefully the line-breaks are in it. I've "renamed" the tool to /sbin/logitech_pairing_tool and since it's for initscript usage, we don't need sudo. exec uses one less process, and means the caller will get the correct exit/signal status from the pairing tool. HTH, igli. #!/bin/sh for f in /sys/class/hidraw/hidraw[0-9]/uevent; do grep -Fq 'HID_NAME=Logitech USB Receiver' "$f" 2>/dev/null && break; done || { echo 'No Logitech USB Receiver present'; exit 1; } f=${f%/uevent} exec /sbin/logitech_pairing_tool "/dev/${f##/}"

jjoerg at 2012-10-25 13:08:23 UTC:

Thanks for the help! I'm running 64-bit Precise on a Dell Vostro 3555. No problems at all.

shto at 2012-10-29 02:35:11 UTC:

followed the steps, but a look at the path /sys/class/hidraw/ it is empty. any idea what could be wrong? I know that a few others above have had this problem, but I could not find mention of a solution...

D. Evans at 2013-04-28 15:47:17 UTC:

Worked perfectly, thank you.

Teja at 2013-05-08 18:54:44 UTC:

I am getting this error... -bash-4.1# ./unifying_pair /dev/hidraw0 Error: 32 write: Broken pipe -bash-4.1#

d:p at 2013-05-20 13:09:34 UTC:

Brilliant. I cannot believe what a lazy bunch Logitech is. They do not even care for the Linux market share. Anyway, thanks for the links!

Ian at 2013-07-22 11:23:34 UTC:

Brilliant, thank you for sharing!

Veit at 2013-11-14 23:12:10 UTC:

Halllo, i have Ubuntu 13.04 64Bit with Kernel 3.10.19 My Logitech K400 do not function. Manual Pairing with solaar is okay. After Reboot K400 without function Same game again ... What should I do?

Processorhog at 2014-01-11 03:34:33 UTC:

MY K800/Performance mouse MX combo does work on the unifying receiver, but everytime the machine boots up, it fails with djprobe throwing error -32. I have to unplug and plug in the usb receiver again and again until it works.

Hans at 2014-09-14 15:11:53 UTC:

On Ubuntu 14.04 mij Performance MX mouse doesn't work. The K800 keyboard does work. The pairing is okay (out-of-the-box) and both mouse and keyboard work on a Windows-machine. I only see a hidraw0 (the receiver) and a hidraw1 (I guess the keyboard). But no hidraw2 for the mouse. When I pair my old M310 mouse using this program that mouse does work and a hidraw2 appears. So there seems to be a specific problem with the MX mouse in combination with this version of Ubuntu. Any suggestions or same experience ? Thanks for sharing the pairing-program, it's very useful !

sjk at 2015-04-26 20:07:45 UTC:

Bravo !!!!

Post a comment