Skip to content

Instantly share code, notes, and snippets.

@shimataro
Created October 15, 2017 20:37
Show Gist options
  • Save shimataro/b9093e982c65f442eee6649e9047265e to your computer and use it in GitHub Desktop.
Save shimataro/b9093e982c65f442eee6649e9047265e to your computer and use it in GitHub Desktop.
#!/bin/bash
# reverse mouse scroll direction
function _reverse_mouse_scroll_direction() {
local IFS=$'\n'
local DEVICE_NAME=$1
local PROP_NAME=$2
for id in $(xinput list | grep -F "${DEVICE_NAME}" | perl -n -e'/id=(\d+)/ && print $1')
do
for prop in $(xinput list-props "$id" | grep -F "${PROP_NAME}" | perl -n -e'/:\s*(-?\d+)\s*,\s*(-?\d+)\s*$/ && print -$1, " ", -$2')
do
eval "xinput set-prop ${id} \"${PROP_NAME}\" $prop"
done
done
}
_reverse_mouse_scroll_direction "Synaptics TouchPad" "Synaptics Scrolling Distance"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment