1

This is about getting 'natural scrolling' aka 'inverted scrolling' to work with ALL applications system-wide with USB mice and trackpoints. This issue is driving me nuts since 12.04 where I fianlly got it working with a bunch of workarounds.

I'm using Ubuntu Studio 18.04 (xfce 4.12 desktop) and there's a 'Natural Scrolling' option in Preferences. It works as expected in browser and file manager, and also in text editors etc. However, i.e. in xfce4-terminal and mousepad (text editor) and some other apps it's still 'unnatural scrolling'

Anyone knows what's the development status on this topic? Am I missing something?

Any help is appreciated before I'll start over and test all those workarounds.

Ubuntu Studio 18.04.1 with xfce 4.12 4.15.0-20-lowlatency #21-Ubuntu SMP PREEMPT

ronso0
  • 111
  • 2
  • 9

2 Answers2

3

IIRC the inconsistent 'reversed scrolling' behaviour even across the default (x)ubuntu apps was due to the different scroll handling in GTK2 and GTK3. Don't know if that still applies..

Anyway, I just found out the "old xinput trick" still works (xUbuntu 18.04.1, xinput version 1.6.2), so I might as well share how it works. And how to make it persist reboots.

Test / temporary solution

List all your currently available pointers and keyboards:

xinput list

Something like this will appear:

⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Logitech USB Laser Mouse                  id=9    [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                     id=12   [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=11   [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)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Power Button                              id=8    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=10   [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                    id=13   [slave  keyboard (3)]

Pick the id of the pointer in question, list all its device properties:

xinput list-props 12

Device 'TPPS/2 IBM TrackPoint':
    Device Enabled (143):   1
    Coordinate Transformation Matrix (145): 1.000000, ...
    libinput Natural Scrolling Enabled (281):   1
    libinput Natural Scrolling Enabled Default (282):   0
    libinput Scroll Methods Available (283):    0, 0, 1
    libinput Scroll Method Enabled (284):   0, 0, 1
    libinput Scroll Method Enabled Default (285):   0, 0, 1
    libinput Button Scrolling Button (286): 2
    ...


This is what we need: libinput Natural Scrolling Enabled (281)

To enable natural scrolling globally i.e. for "TPPS/2 IBM TrackPoint" (for the current session), first turn it OFF in 'Mouse & Touchpad' preferences.
Enter one of those two lines below, hit Enter. (both do the same, because to read or write a property you can use either its entire(!) name or its ID)

xinput set-prop 12 "libinput Natural Scrolling Enabled" 1

xinput set-prop 12 "281" 1

Now test it in applications where naturalscroling wouldn't work via system preferences.

Permanent solution

If the above test worked on your machine, you can apply the changes everytime you log into your session with a small startup script. The script part that matches deviceName is from this answer about button maps by @zerobandwidth).

Save the code below as natural_scrolling.sh in your home directory or in /any/path/youLike

#!/bin/bash
# Find all xinput devices whose name matches any of the arguments passed here,
# then set the Natural Scrolling' property to '1' regardless of its
# current state.

# expect multiple arguments, store them as array
deviceNames="$@"

# exit if no argument is passed
if [ "$deviceNames" = "" ]; then
        echo "No argument received, exiting."
        echo "Call this script with argument(s) like 'Logitech' that match"
        echo "any of your attached pointer devices."
    exit 1
fi

for deviceName in $deviceNames
do
    deviceId=$(xinput --list | awk -v search="$deviceName" \
    '$0 ~ search {match($0, /id=[0-9]+/);\
                  if (RSTART) \
                    print substr($0, RSTART+3, RLENGTH-3)\
                 }'\
     )
  # set device-specific property (works i.e for 'TrackPoint' & 'Logitech')
  xinput set-prop $deviceId "libinput Natural Scrolling Enabled" 1
done

Mark the script executable:

chmod +x natural_scrolling.sh

Call it with unique(!) device_name string(s) as argument:

/any/path/youLike/natural_scrolling.sh Logitech TrackPoint

Add it to your startup applications, i.e via Session & Startup preferences in xfce and test it by logging out & back in again.

ronso0
  • 111
  • 2
  • 9
2

Alas, I don't have enough reputation to comment, so I'm going to have to add this as an answer. For anyone stumbling upon this, there's a very small error in the code above. The penultimate line:

xinput set-prop $id "libinput Natural Scrolling Enabled" 1

Should read:

xinput set-prop $deviceId "libinput Natural Scrolling Enabled" 1

Also, I use a Logitech Ultrathin Mouse and for who-knows-what reason, it connects both as a mouse and keyboard, and therefore appears twice in xinput list. I therefore added piping the output to head -1 to limit what gets returned to just the first entry (which in my case is always the mouse):

...
                    print substr($0, RSTART+3, RLENGTH-3)\
                 }' | head -1 \
     )
...