Linux: How to Set Mouse Speed

By Xah Lee. Date:

Here's how to set mouse's speed.

# set mouse speed to twice as fast
xset m 2 0
# set mouse speed to 3 x, when moved 4 counts within 10 milisecond
xset m 3 4
# set mouse speed to default
xset m default

The first number is acceleration, and second number is threshold.

The acceleration can be a fraction.

# set mouse speed to 2.5 times as fast
xset m 5/2 0

The m option controls the mouse parameters; it may be abbreviated to 'm'. Of course, it applies to most pointing devices, not just mice. The parameters for the pointing device are `acceleration' and `threshold'. The acceleration can be specified as an integer, or as a simple fraction. Threshold is just an integer. The setting is applied to all connected pointing devices. xinput(1) should be used if you need device-specific settings.

By default the pointer (the on-screen representation of the pointing device) will go `acceleration' times as fast when the device travels more than `threshold' mickeys (i.e. wouldbe pixels) in 10 ms, including a small transition range. This way, the pointing device can be used for precise alignment when it is moved slowly, yet it can be set to travel across the screen in a flick of the wrist when desired. One or both parameters for the m option can be omitted, but if only one is given, it will be interpreted as the acceleration. If no param‐ eters or the flag 'default' is used, the system defaults will be set.

Set Up Each Different Mouse

If you have 2 mouses, or trackpad and mouse, or any number of input devices, you can set them each independently, using xinput.

List Devices

First, list your devices to find the name. Type xinput list.

xah mouses keyboard 20151102 062053
from left to right: { • CM Storm Recon, • Logitech Trackman Marble Mouse Review, • Logitech G600, • Logitech G700}. The keyboard is Truly Ergonomic Keyboard.

I have 3 mouses and 1 trackball plugged-in. Here's my output

~/ $ xinput list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Logitech Gaming Mouse G600                id=8    [slave  pointer  (2)]
⎜   ↳ Logitech Gaming Mouse G600                id=9    [slave  pointer  (2)]
⎜   ↳ LVT Recon gaming mouse                    id=10   [slave  pointer  (2)]
⎜   ↳ LVT Recon gaming mouse                    id=11   [slave  pointer  (2)]
⎜   ↳ Logitech USB Trackball                    id=12   [slave  pointer  (2)]
⎜   ↳ Logitech G700 Laser Mouse                 id=15   [slave  pointer  (2)]
⎜   ↳ Logitech G700 Laser Mouse                 id=16   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Power Button                              id=7    [slave  keyboard (3)]
    ↳ TrulyErgonomic.com Truly Ergonomic Computer Keyboard      id=13   [slave  keyboard (3)]
    ↳ TrulyErgonomic.com Truly Ergonomic Computer Keyboard      id=14   [slave  keyboard (3)]
~/ $

Some mouse shows up twice. For example, “Logitech Gaming Mouse G600” has id 8 and 9.

Show Property

To show a device's settings, type:

xinput list-props mouse_brand_name

or

xinput list-props id

Example:

~/ $ xinput list-props "Logitech USB Trackball"
Device 'Logitech USB Trackball':
        Device Enabled (134):   1
        Coordinate Transformation Matrix (136): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        Device Accel Profile (263):     0
        Device Accel Constant Deceleration (264):       1.000000
        Device Accel Adaptive Deceleration (265):       1.000000
        Device Accel Velocity Scaling (266):    10.000000
        Device Product ID (252):        1133, 50184
        Device Node (253):      "/dev/input/event19"
        Evdev Axis Inversion (267):     0, 0
        Evdev Axes Swap (269):  0
        Axis Labels (270):      "Rel X" (144), "Rel Y" (145)
        Button Labels (271):    "Button Left" (137), "Button Middle" (138), "Button Right" (139), "Button Wheel Up" (140), "Button Wheel Down" (141), "Button Horiz Wheel Left" (142), "Button Horiz Wheel Right" (143), "Button Side" (256), "Button Extra" (257)
        Evdev Middle Button Emulation (272):    0
        Evdev Middle Button Timeout (273):      50
        Evdev Third Button Emulation (274):     0
        Evdev Third Button Emulation Timeout (275):     1000
        Evdev Third Button Emulation Button (276):      3
        Evdev Third Button Emulation Threshold (277):   20
        Evdev Wheel Emulation (278):    0
        Evdev Wheel Emulation Axes (279):       0, 0, 4, 5
        Evdev Wheel Emulation Inertia (280):    10
        Evdev Wheel Emulation Timeout (281):    200
        Evdev Wheel Emulation Button (282):     4
        Evdev Drag Lock Buttons (283):  0
~/ $
~/ $ xinput list-props 8
Device 'Logitech Gaming Mouse G600':
        Device Enabled (134):   1
        Coordinate Transformation Matrix (136): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        Device Accel Profile (263):     0
        Device Accel Constant Deceleration (264):       1.000000
        Device Accel Adaptive Deceleration (265):       1.000000
        Device Accel Velocity Scaling (266):    10.000000
        Device Product ID (252):        1133, 49738
        Device Node (253):      "/dev/input/event15"
        Evdev Axis Inversion (267):     0, 0
        Evdev Axes Swap (269):  0
        Axis Labels (270):      "Rel X" (144), "Rel Y" (145), "Rel Horiz Wheel" (261), "Rel Vert Wheel" (262)
        Button Labels (271):    "Button Left" (137), "Button Middle" (138), "Button Right" (139), "Button Wheel Up" (140), "Button Wheel Down" (141), "Button Horiz Wheel Left" (142), "Button Horiz Wheel Right" (143), "Button Side" (256), "Button Extra" (257), "Button Forward" (258), "Button Back" (259), "Button Task" (260), "Button Unknown" (255), "Button Unknown" (255), "Button Unknown" (255), "Button Unknown" (255), "Button Unknown" (255), "Button Unknown" (255), "Button Unknown" (255), "Button Unknown" (255), "Button Unknown" (255), "Button Unknown" (255), "Button Unknown" (255), "Button Unknown" (255)
        Evdev Middle Button Emulation (272):    0
        Evdev Middle Button Timeout (273):      50
        Evdev Third Button Emulation (274):     0
        Evdev Third Button Emulation Timeout (275):     1000
        Evdev Third Button Emulation Button (276):      3
        Evdev Third Button Emulation Threshold (277):   20
        Evdev Wheel Emulation (278):    0
        Evdev Wheel Emulation Axes (279):       0, 0, 4, 5
        Evdev Wheel Emulation Inertia (280):    10
        Evdev Wheel Emulation Timeout (281):    200
        Evdev Wheel Emulation Button (282):     4
        Evdev Drag Lock Buttons (283):  0
~/ $

Set Property

To set the speed, use this:

xinput --set-prop device_id_or_name "Device Accel Constant Deceleration" number

# make this trackball's speed twice as slow
xinput --set-prop "Logitech USB Trackball" "Device Accel Constant Deceleration" 2
# make this trackball's speed twice as fast
xinput --set-prop "Logitech USB Trackball" "Device Accel Constant Deceleration" 0.5
# reverse the vertical axes
xinput --set-prop "Logitech USB Trackball" "Evdev Axis Inversion" 0, 1

Save any of the above in a file as ~/.xprofile.

How to Swap Mouse Buttons

Linux: How to Swap Mouse Buttons

Mouse topic

  1. Linux: Mouse Hover to Auto-Raise Window
  2. Linux: Mouse Hover-Click
  3. Linux: Set Mouse Single-Click to Open File
  4. Linux: How to Set Mouse Speed
  5. Linux: How to Swap Mouse Buttons
  6. Linux: Set Trackball/Mouse Do Scroll
  7. Linux: Setup Accelerated Scroll and AutoScroll
  8. Linux: X11 Mouse Button Numbering

Ask me question on patreon