Episode: 3819 Title: HPR3819: Remapping Mouse Buttons with XBindKeys on Linux Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3819/hpr3819.mp3 Transcribed: 2025-10-25 05:55:49 --- This is Hacker Public Radio Episode 3819 for Thursday, the 23rd of March 2023. Today's show is entitled Remapping Mouse Buttons with X-Bind Keys on Linux. It is hosted by John Culp and is about 10 minutes long. It carries a clean flag. The summary is I explain how I assign different functions to the spare buttons on my track ball mice. Hey everybody, this is John Culp in Lafayette, Louisiana, and it's nice to be talking to you all again. It's been a very, very long time. Some of you, if you are new listeners, probably don't even know who I am, but there was a time when I was contributing shows all the time, but it's been more than a year. I came across something today that I thought, well, maybe this is my way back in, at least to contributor in episode. I'll confess I haven't been listening very much either, but I do want to at least have one episode per year with my name on it so that I can still be considered a contributing member of the community. I might even be able to do more than that because I'm back in a job where I've got a little bit more free time than I had for the last seven years when I've been an administrator, and I'm back in the regular faculty of the School of Music now, so I've got more time and a little bit more freedom to do this kind of thing. What I thought I would talk about today is something I just figured out how to do, and that is to remap the buttons on a couple of my track ball mice. I've got the oldest one I have is a Kensington expert mouse. Let me see if I can see what the model number. It's model number K64325, and I don't know when it was made, but I feel like I've had it for about 15 years. I bought it at a time when I was doing a lot of work on a music program called Finale, and it involved clicking and dragging things and a lot of double clicking, and it was kind of fatiguing on my wrist, and I wanted to get a mouse that would allow me to map buttons to do some of those things more easily. The Kensington expert mouse, if you've never seen one, you should look up a picture of it. It's a large mouse. It's got four big buttons that surround a track ball in the middle and around the ball is a scroll wheel that you can just spin around and around in either direction around the ball, and the lower left is by default configured to left click. The lower right is configured to right click, and I don't know what the upper two buttons are configured to by default. It feels like on Linux, when I didn't do any kind of intervention, the upper right button was like a back button on the browser, and the upper left, I don't think it did anything, as far as I could tell it, it did nothing. When I was working a lot in Finale, what I did was I assigned the upper left button to double click, and the upper right to click and hold, or click and drag, and I was able to do that because at that time I was using a Mac, and there is a configuration tool for the Kensington expert mouse on Mac that makes it really easy to configure these things. The other mouse is a Logitech, it's one of those with that kind of reddish, purple-ish track ball, shaped kind of like a slug, it's got a large button on the left, and another one on the right that are left and right click, and kind of embedded in each of those is a tiny button that I believe by default is configured to do back and forward, like browser navigation kinds of things. The reason I got on to this today was I really wanted to be able to use the Logitech mouse also does not have any kind of scrolling capability, and that's what initially prompted me to finally sort this out, because I wanted those little buttons instead of going back and forward to be page up and page down to help me navigate web pages a little bit more easily. And what I found, I think I found the initial ability to do this on the wonderful Arch wiki, but I found that you could use a tool called X-Bind keys that would allow you to specify a button to bind and then a command to run whenever it sends that button had been hit. And so if you look at the show notes, you'll see I lay out a little bit of background on it and explanation, and then I give some the sample configuration files that I used to make it all work. You have to essentially install a couple of dependencies, X-Bind keys, that's all one word, X-B-I-N-D-K-E-Y-S, just install that from your repository. You're also going to need one of the virtual keyboard kind of things, I actually installed two of them, well they were already installed, X-D-O-Tool and X-V-K-B-D. I used those all the time in my bladder voice recognition configurations, and so I already had them installed, but I did not have X-Bind keys installed. And if you're trying to figure out what button number or key is being pressed, then you might need also to use X-E-V, which I think is going to be installed on your systems by default if you have a regular Linux desktop environment. So once you have those dependencies installed, you just need to create a configuration file in your home directory, it'll just be slash home slash username slash dot X-Bind keys, R-C, is the name of the configuration file. And then you just to configure those two buttons on my Kensington, I just needed four lines of code I think, or maybe five, something like that. I put a couple of comments also. But one thing I found was that I needed to use X-D-O-Tool for the double click and the click and drag, because I could not figure out a way to make X-V K-B-D do clicking things. It only did keyboard things. So it looks like the way these set up things, configuration set up things work is that on the first line, you tell it the command you want to run. And on the second line, you tell it which button is going to trigger that command. So in order to make the upper left button do a double click, I put on the first line in quotes X-D-O-Tool, sorry, let me give you the clean command and then tell you the hack I had to use to make it work. X-D-O-Tool, click one, semicolon, X-D-O-Tool, click one. And what that does is it tells it to do a virtual click using button one of the mouse. Now that didn't work at first and then when I was reading around on various sites where people try to do this kind of thing, somebody suggested putting a sleep command before the word click on the X-D-O-Tool and because I don't know, maybe it was just happening too fast and it choked on itself. So I tried that, I put X-D-O-Tool, space, sleep, space 0.2, space, click, space, one, followed by the semicolon and then just X-D-O-Tool, space, click, space, one and then close quote. And I signed that to button number two, which is the upper left button on the mouse. And the next time I restarted X bind keys, it worked. So apparently you need to give it a little bit of sleep before trying to do the virtual clicks if you're using X-D-O-Tool with this. So that worked just great. I'm very, very happy now that I've got the upper left button assigned to double click and the upper right to click and drag. Now on the other one, on the Logitech mouse, I used XV KBD to do the tell it to assign button number eight to the page down key and button number nine to the page up key from the keyboard. And you could probably use X-D-O-Tool for this as well, but for whatever reason, that was actually the one I did first. And the first page I found where somebody was telling how to do this, they were using XV KBD and since it worked, I didn't bother going any further trying to figure that out. It was only after turning my attention to the Kensington mouse. Did I just realize, oh, I can't use that because it doesn't do clicks, it only does keystrokes. But anyway, I hope that's an explanation to get you going. If you wanted, I've got examples in the show notes and links to some of the tools so you can read further about it if you want. But otherwise, I think that's going to be about it slow, sorry, short episode today. I'm considering doing a show or two about one of my recent hobbies and that is I've learned to write a motorcycle. Something I've wanted to do for a long time and I've just accomplished this past few months. And so maybe that's an appropriate topic for hacker public radio as well. But anyway, for now I think that's going to be it. I'm going to sign off. This has been John Cobb from Lafayette, Louisiana. Nice talking to you all again. Bye bye. You have been listening to Hacker Public Radio at Hacker Public Radio. Today's show was contributed by a HBR listener like yourself. If you ever thought of recording podcasts, click on our contribute link to find out how easy it really is. Posting for HBR has been kindly provided by an honesthost.com, the internet archive and our syncs.net. On the Saldois status, today's show is released under Creative Commons Attribution 4.0 International