Natural Scrolling + Left Handed Mouse Buttons

Things described below are done on my Gentoo Linux on 2015-08-15. However they should apply any X11 Systems such as Debian, Ubuntu, or Arch Linux as well, because none of them are depending on Gentoo specific tools.

Problem: Natural scrolling

This should be easy. Both xfce4 and gnome have config to reverse scroll direction. However, they don’t always reverse only on some GUI apps (such as evince pdf viewer)

xmodmap seems to solve this issue, but it does not.

xmodmap has another issue that if you unplug/plug USB mouse you have to apply xmodmap again.

Let’s find a solution which doesn’t depend on xmodmap, and which also works for any apps including evince.

Also I want to swap left click and right click.

Solution: /etc/X11/xorg.conf.d

Add /etc/X11/xorg.conf.d/99-ujihisa.conf

Section "InputClass"
        Identifier "natural scrolling for mouse"
        MatchDriver "evdev"
        Option "ButtonMapping" "3 2 1 5 4"

Section "InputClass"
        Identifier "natural scrolling for touchpad"
        MatchDriver "synaptics"
        Option      "VertScrollDelta"          "-111"
        Option      "HorizScrollDelta"         "-111"

After spending couple days I figured out that the above config works.

Notes for the process finding that solution

  • Tried to modify files under /usr/share/X11/xorg.conf.d/ which at-home-modifier (i.e. x11-drivers/xf86-input-evdev) also uses
  • Specifying wrong value (e.g. Driver "mouse") is very dangerous. It can disable any user inputs, and you may have to shutdown computer by holding the power button.
  • If you give wrong value the config can be silently ignored. /var/log/Xorg.0.log can be helpful for debugging
  • man xorg.conf.d, man synaptics, and man evdev are helpful
  • You may have seen ZAxisMapping for inverting scroll. Forget about it. It won’t work


When your Apple Bluetooth Keyboard disconnects immediately after connection

  • Gentoo Linux

Try bluetoothctl -a, instead of just bluetoothctl.

$ bluetoothctl
scan on
scan off (once you find your device)
pair {the id}
{input the pin from the keyboard}

If it still doesn’t work

modprobe applesmc