3

I recently switched to Ubuntu from Win7, cause I was tired of spending days trying to figure out how to run devtools made for linux run properly on windows....and so far I'm happy with the decision. The only thing I still couldn't figure out is how to properly configure my kensington trackball.

I have read all the pre-existing answers, but I still can't figure it out, so I apologize if this has been answered before.

Under Windows, I was used to having the TrackballWorks app, which lets me easily configure button mappings and such.

Under linux, I read online that I shall edit the xorg.conf file, but nowhere di I find a detailed manual page / specific tutorial.

Could someone kindly enlighten me?

1
  • I got here because I recently had to configure a Kensington Slimblade Trackball to get the scroll working and had trouble figuring out how to do it. I've documented the solution here: askubuntu.com/questions/1332909/…
    – elias
    Apr 21, 2021 at 12:20

1 Answer 1

4

xorg.conf files tend to be a pain. You can go ahead and edit it if you want, but, personally, I would not.

There's a commandline tool called xbindkeys. It allows you to route specific button presses to commands. There's a full explanation here, but I will try to explain it briefly here.

Firstly, if you want to bind the keys to actions, you need to set up keyboard shortcuts for them (Settings > Keyboard > Shortcuts). You do not need to do this to launch programs.

You'll need to install xbindkeys and xautomation.

sudo apt-get install xbindkeys xautomation

Then, open a terminal (Ctrl+Alt+T) and run the xev command. It should pop up a small little window with a white box and a black background. Try not to move the mouse (it will make things hard to find), and click the button you want to set up. Then, go back to the terminal and find the last ButtonPress and/or ButtonRelease events (either one). The event will give you a number for the button you pressed (button <number>, towards the end). Remember that number.

Now, in a new terminal instance, do nano ~/.xbindkeysrc. This will create a text file by which you can configure xbindkeys.

For that key, create an entry like so:

"command"
 b: <button number>

For example, say you wanted to open Firefox when you pressed the mouse's "home" button (for me, button 10):

# Run Firefox when "home" pressed
"firefox"
 b: 10

Or, if you wanted to bind it to a desktop action (like minimize all windows, like shown below), you would tell it to simulate the keybinding with xte:

# Minimize all windows on "2" button press
"xte 'keydown Control_L' 'keydown Alt_L' 'key D' 'keyup Alt_L' 'keyup Control_L'"
  b: 11

You would repeat this process for the other buttons.

When you're done, save the file (Ctrl+O and Enter), and close nano (Ctrl+X).

Then, just launch xbindkeys outside the terminal (Alt+F2, then type xbindkeys).

However, you will want it to autolaunch after every shutdown. Add it to your autostart configuration (Settings > Session > Startup > Application Autostart, add xbindkeys).

1
  • If a solution works, mark it as the accepted answer (green checkmark below the vote count). Please avoid writing comments that simply say "it works!" -- comments on Stack Exchange sites are not designed for this purpose. Thank you!
    – hal7df
    Jun 23, 2014 at 20:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .